Package org.esa.snap.core.util.io
Class ObservableInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.esa.snap.core.util.io.ObservableInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
An input stream which can be used to observer progress of reading from some other input stream.
-
Field Summary
Fields inherited from class java.io.FilterInputStream
in -
Constructor Summary
ConstructorsConstructorDescriptionObservableInputStream(InputStream in, long size, InputStreamObserver listener) Constructs an object to observer the progress of an input stream.ObservableInputStream(InputStream in, InputStreamObserver listener) Constructs an object to observer the progress of an input stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()OverridesFilterInputStream.closeto close the progress observer as well as the stream.longlongintread()OverridesFilterInputStream.readto update the progress observer after the read.intread(byte[] b) OverridesFilterInputStream.readto update the progress observer after the read.intread(byte[] b, int off, int len) OverridesFilterInputStream.readto update the progress observer after the read.voidreset()OverridesFilterInputStream.resetto reset the progress observer as well as the stream.longskip(long n) OverridesFilterInputStream.skipto update the progress observer after the skip.Methods inherited from class java.io.FilterInputStream
available, mark, markSupportedMethods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
ObservableInputStream
Constructs an object to observer the progress of an input stream.- Parameters:
in- The input stream to be monitored.listener- the listener to be informed
-
ObservableInputStream
Constructs an object to observer the progress of an input stream.- Parameters:
in- The input stream to be monitored.listener- the listener to be informed
-
-
Method Details
-
getNumBytesTotal
public long getNumBytesTotal() -
getNumBytesRead
public long getNumBytesRead() -
getObserver
-
read
OverridesFilterInputStream.readto update the progress observer after the read.- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
OverridesFilterInputStream.readto update the progress observer after the read.- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
OverridesFilterInputStream.readto update the progress observer after the read.- Overrides:
readin classFilterInputStream- Throws:
IOException
-
skip
OverridesFilterInputStream.skipto update the progress observer after the skip.- Overrides:
skipin classFilterInputStream- Throws:
IOException
-
close
OverridesFilterInputStream.closeto close the progress observer as well as the stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterInputStream- Throws:
IOException
-
reset
OverridesFilterInputStream.resetto reset the progress observer as well as the stream.- Overrides:
resetin classFilterInputStream- Throws:
IOException
-