Package org.apache.commons.vfs2.util
Class MonitorInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- java.io.BufferedInputStream
-
- org.apache.commons.vfs2.util.MonitorInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class MonitorInputStream extends java.io.BufferedInputStreamAn InputStream that provides buffering and end-of-stream monitoring.
-
-
Constructor Summary
Constructors Constructor Description MonitorInputStream(java.io.InputStream in)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()Returns 0 if the stream is at eof, else the underlaying inputStream will be queried.voidclose()Closes this input stream and releases any system resources associated with the stream.longgetCount()Get the nuber of bytes read by this input stream.protected voidonClose()Called after the stream has been closed.intread()Reads a character.intread(byte[] buffer, int offset, int length)Reads bytes from this input stream.
-
-
-
Method Detail
-
available
public int available() throws java.io.IOExceptionReturns 0 if the stream is at eof, else the underlaying inputStream will be queried.- Overrides:
availablein classjava.io.BufferedInputStream- Returns:
- The number of bytes that are available.
- Throws:
java.io.IOException- if an error occurs.- Since:
- 2.0
-
read
public int read() throws java.io.IOExceptionReads a character.- Overrides:
readin classjava.io.BufferedInputStream- Returns:
- The character that was read as an integer.
- Throws:
java.io.IOException- if an error occurs.
-
read
public int read(byte[] buffer, int offset, int length) throws java.io.IOExceptionReads bytes from this input stream.- Overrides:
readin classjava.io.BufferedInputStream- Parameters:
buffer- A byte array in which to place the characters read.offset- The offset at which to start reading.length- The maximum number of bytes to read.- Returns:
- The number of bytes read.
- Throws:
java.io.IOException- if an error occurs.
-
close
public void close() throws java.io.IOExceptionCloses this input stream and releases any system resources associated with the stream.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.BufferedInputStream- Throws:
java.io.IOException- if an error occurs.
-
onClose
protected void onClose() throws java.io.IOExceptionCalled after the stream has been closed. This implementation does nothing.- Throws:
java.io.IOException- if an error occurs.
-
getCount
public long getCount()
Get the nuber of bytes read by this input stream.- Returns:
- The number of bytes read by this input stream.
-
-