public class OutputStreamWrapper
extends java.io.OutputStream
OutputStream wrapper for a Stream.| Modifier and Type | Field and Description |
|---|---|
private boolean |
closable
Flag which allow the wrapped stream to be closed.
|
private Stream |
out
The wrapped stream.
|
private static int |
WRITE_CHUNK_SIZE
The chunk to write at once to the remote
stream, via in the write(byte[], int, int)
implementation. |
| Constructor and Description |
|---|
OutputStreamWrapper(Stream out)
Creates an instance with the associated stream.
|
OutputStreamWrapper(Stream out,
boolean closable)
Creates an instance with the associated stream.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the underlying stream and releases OS resources associated with it.
|
void |
flush()
Flushes the underlying stream.
|
void |
setClosable()
Makes the stream closable back again by resetting the
closable property. |
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)
Writes the specified byte to this output stream (only the low order 8
bits are written, the high order 24 bits are ignored).
|
private Stream out
private boolean closable
private static final int WRITE_CHUNK_SIZE
stream, via in the write(byte[], int, int)
implementation.public OutputStreamWrapper(Stream out)
public OutputStreamWrapper(Stream out, boolean closable)
closable - Configures whether the wrapper is closable. The attribute can be reset to true using
setClosable() method.public void write(int b)
throws java.io.IOException
write in class java.io.OutputStreamb - The byte 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.public void write(byte[] b)
throws java.io.IOException,
java.lang.NullPointerException
write in class java.io.OutputStreamb - 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.OutputStreamb - 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()
setClosable() in advance.close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.OutputStreampublic void flush()
throws java.io.IOException
flush in interface java.io.Flushableflush in class java.io.OutputStreamjava.io.IOExceptionpublic void setClosable()
closable property.