Package org.apache.commons.vfs2.util
Class MonitorOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.io.BufferedOutputStream
org.apache.commons.vfs2.util.MonitorOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
An OutputStream that provides buffering and end-of-stream monitoring.
-
Field Summary
Fields inherited from class java.io.BufferedOutputStream
buf, count
Fields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a MonitorOutputStream from the passed OutputStream.MonitorOutputStream
(OutputStream out, int bufferSize) Constructs a MonitorOutputStream from the passed OutputStream and with the specified buffer size. -
Method Summary
-
Constructor Details
-
MonitorOutputStream
Constructs a MonitorOutputStream from the passed OutputStream.- Parameters:
out
- The output stream to wrap.
-
MonitorOutputStream
Constructs a MonitorOutputStream from the passed OutputStream and with the specified buffer size.- Parameters:
out
- The output stream to wrap.bufferSize
- The buffer size to use.- Since:
- 2.4
-
-
Method Details
-
assertOpen
Check if file is still open.This is a workaround for an oddity with Java's BufferedOutputStream where you can write to even if the stream has been closed.
- Throws:
FileSystemException
- if already closed.- Since:
- 2.0
-
close
Closes this output stream.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.
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterOutputStream
- Throws:
IOException
- if an IO error occurs.
-
flush
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classBufferedOutputStream
- Throws:
IOException
- if an error occurs.- Since:
- 2.0
-
onClose
Called after this stream is closed.This implementation does nothing.
- Throws:
IOException
- if an error occurs.
-
write
- Overrides:
write
in classFilterOutputStream
- Parameters:
b
- The byte array.- Throws:
IOException
- if an error occurs.- Since:
- 2.0
-
write
- Overrides:
write
in classBufferedOutputStream
- Parameters:
b
- The byte array.off
- The offset into the array.len
- The number of bytes to write.- Throws:
IOException
- if an error occurs.- Since:
- 2.0
-
write
- Overrides:
write
in classBufferedOutputStream
- Parameters:
b
- The character to write.- Throws:
IOException
- if an error occurs.- Since:
- 2.0
-