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
public class MonitorOutputStream
- extends BufferedOutputStream
An OutputStream that provides buffering and end-of-stream monitoring.
- Author:
- Commons VFS team
Method Summary |
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)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MonitorOutputStream
public MonitorOutputStream(OutputStream out)
close
public void close()
throws IOException
- Closes this output stream.
- Specified by:
close
in interface Closeable
- Overrides:
close
in class FilterOutputStream
- Throws:
IOException
- if an error occurs.
write
public void write(int b)
throws IOException
- Overrides:
write
in class BufferedOutputStream
- Parameters:
b
- The character to write.
- Throws:
IOException
- if an error occurs.- Since:
- 2.0
write
public void write(byte[] b,
int off,
int len)
throws IOException
- Overrides:
write
in class BufferedOutputStream
- 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
flush
public void flush()
throws IOException
- Specified by:
flush
in interface Flushable
- Overrides:
flush
in class BufferedOutputStream
- Throws:
IOException
- if an error occurs.- Since:
- 2.0
write
public void write(byte[] b)
throws IOException
- Overrides:
write
in class FilterOutputStream
- Parameters:
b
- The byte array.
- Throws:
IOException
- if an error occurs.- Since:
- 2.0
assertOpen
protected void assertOpen()
throws FileSystemException
- 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 an error occurs.- Since:
- 2.0
onClose
protected void onClose()
throws IOException
- Called after this stream is closed. This implementation does nothing.
- Throws:
IOException
- if an error occurs.
Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.