public class MonitorOutputStream
extends java.io.BufferedOutputStream
| Modifier and Type | Field and Description |
|---|---|
private java.util.concurrent.atomic.AtomicBoolean |
finished |
| Constructor and Description |
|---|
MonitorOutputStream(java.io.OutputStream out)
Constructs a MonitorOutputStream from the passed OutputStream
|
MonitorOutputStream(java.io.OutputStream out,
int bufferSize)
Constructs a MonitorOutputStream from the passed OutputStream and with the specified buffer size
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
assertOpen()
Check if file is still open.
|
void |
close()
Closes this output stream.
|
void |
flush() |
protected void |
onClose()
Called after this stream is closed.
|
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
public MonitorOutputStream(java.io.OutputStream out)
out - The output stream to wrap.public MonitorOutputStream(java.io.OutputStream out,
int bufferSize)
out - The output stream to wrap.bufferSize - The buffer size to use.public void close()
throws java.io.IOException
This makes sure the buffers are flushed, close the output stream and it will call onClose() and re-throw
last exception from any of the three.
This does nothing if the stream is closed already.
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.FilterOutputStreamjava.io.IOException - if an error occurs.public void write(int b)
throws java.io.IOException
write in class java.io.BufferedOutputStreamb - The character to write.java.io.IOException - if an error occurs.public void write(byte[] b,
int off,
int len)
throws java.io.IOException
write in class java.io.BufferedOutputStreamb - The byte array.off - The offset into the array.len - The number of bytes to write.java.io.IOException - if an error occurs.public void flush()
throws java.io.IOException
flush in interface java.io.Flushableflush in class java.io.BufferedOutputStreamjava.io.IOException - if an error occurs.public void write(byte[] b)
throws java.io.IOException
write in class java.io.FilterOutputStreamb - The byte array.java.io.IOException - if an error occurs.protected void assertOpen()
throws FileSystemException
This is a workaround for an oddity with Java's BufferedOutputStream where you can write to even if the stream has been closed.
FileSystemException - if already closed.protected void onClose()
throws java.io.IOException
This implementation does nothing.
java.io.IOException - if an error occurs.