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:
- Closeable,- AutoCloseable
An InputStream that provides buffering and end-of-stream monitoring.
- 
Field SummaryFields inherited from class java.io.BufferedInputStreambuf, marklimit, markpos, posFields inherited from class java.io.FilterInputStreamin
- 
Constructor SummaryConstructorsConstructorDescriptionConstructs a MonitorInputStream from the passed InputStream.MonitorInputStream(InputStream in, int bufferSize) Constructs a MonitorInputStream from the passed InputStream and with the specified buffer size.
- 
Method SummaryModifier and TypeMethodDescriptionintReturns 0 if the stream is at EOF, else the underlying inputStream will be queried.voidclose()Closes this input stream and releases any system resources associated with the stream.protected voidThis method exists in order to allow overriding whether to actually close the underlying stream (VFS-805).longgetCount()Gets the number 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.Methods inherited from class java.io.BufferedInputStreammark, markSupported, reset, skipMethods inherited from class java.io.FilterInputStreamread
- 
Constructor Details- 
MonitorInputStreamConstructs a MonitorInputStream from the passed InputStream.- Parameters:
- in- The input stream to wrap.
 
- 
MonitorInputStreamConstructs a MonitorInputStream from the passed InputStream and with the specified buffer size.- Parameters:
- in- The input stream to wrap.
- bufferSize- The buffer size to use.
- Since:
- 2.4
 
 
- 
- 
Method Details- 
availableReturns 0 if the stream is at EOF, else the underlying inputStream will be queried.- Overrides:
- availablein class- BufferedInputStream
- Returns:
- The number of bytes that are available.
- Throws:
- IOException- if an error occurs.
- Since:
- 2.0
 
- 
closeCloses this input stream and releases any system resources associated with the stream.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Overrides:
- closein class- BufferedInputStream
- Throws:
- IOException- if an error occurs.
 
- 
closeSuperThis method exists in order to allow overriding whether to actually close the underlying stream (VFS-805). There are cases where closing that stream will consume any amount of remaining data. In such cases closing a different entity instead (such as an HttpResponse) may be more appropriate.- Throws:
- IOException- if an IO error occurs.
 
- 
getCountGets the number of bytes read by this input stream.- Returns:
- The number of bytes read by this input stream.
 
- 
onCloseCalled after the stream has been closed. This implementation does nothing.- Throws:
- IOException- if an error occurs.
 
- 
readReads a character.- Overrides:
- readin class- BufferedInputStream
- Returns:
- The character that was read as an integer.
- Throws:
- IOException- if an IO error occurs.
 
- 
readReads bytes from this input stream.- Overrides:
- readin class- 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:
- IOException- if an IO error occurs.
 
 
-