private static class SaxWriterImpl.FileOutputStreamWrapper
extends java.io.OutputStream
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
fileName
File name.
|
private boolean |
isStarted
Lazy initialization flag.
|
private Stream |
stream
Buffered output Stream.
|
Modifier | Constructor and Description |
---|---|
private |
FileOutputStreamWrapper(java.lang.String source)
Constructor accepting a file name, which will read after first call.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close current stream and reset state.
|
private void |
init(boolean canWrite)
Initialization method which creates stream wrapper.
|
void |
write(byte[] b)
Writes the entire contents of the specified byte array to this output stream.
|
void |
write(byte[] b,
int off,
int len)
Writes
len bytes from the specified byte array starting
at offset off in this output stream. |
void |
write(int b)
Write one byte into the stream.
|
private final java.lang.String fileName
private volatile boolean isStarted
private Stream stream
private FileOutputStreamWrapper(java.lang.String source)
source
- A file name.public void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
b
- the data to write.java.io.IOException
public void write(byte[] b) throws java.io.IOException, java.lang.NullPointerException
write
in class java.io.OutputStream
b
- The byte array to write.java.io.IOException
- if an I/O error occurs. In particular, an IOException may be
thrown if the output stream has been closed.java.lang.NullPointerException
- if the array is null
.public void write(byte[] b, int off, int len) throws java.io.IOException, java.lang.NullPointerException, java.lang.IndexOutOfBoundsException
len
bytes from the specified byte array starting
at offset off
in this output stream. Element b[off] is
the first byte written and b[off+len-1] is the last byte written.write
in class java.io.OutputStream
b
- The array of bytes to write.off
- the start offset in the array.len
- the number of bytes to write.java.io.IOException
- if an I/O error occurs. In particular, an IOException may be
thrown if the output stream has been closed.java.lang.NullPointerException
- if the array is null
.java.lang.IndexOutOfBoundsException
- if the offset or length are negative, or if offset + length
is larger than the length of the array.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.OutputStream
java.io.IOException
private void init(boolean canWrite) throws java.io.IOException
canWrite
- if true
than file will open in read/write mode, otherwise only in
read mode.java.io.IOException
- In case of I/O errors.