public class ProgressInputStream extends FilterInputStream
| Modifier and Type | Class and Description |
|---|---|
static class |
ProgressInputStream.ProgressInterruptedIOException
An InterruptedIOException that was thrown by a ProgressInputStream
because its ProgressListener signaled that the operation was
aborted.
|
in| Constructor and Description |
|---|
ProgressInputStream(ProgressListener progressListener,
File file)
Constructs an object to monitor the progress of an input stream reading from a file.
|
ProgressInputStream(ProgressListener progressListener,
InputStream in,
long size)
Constructs an object to monitor the progress of an input stream.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Overrides
FilterInputStream.close
to close the progress monitor as well as the stream. |
int |
read()
Overrides
FilterInputStream.read
to update the progress monitor after the read. |
int |
read(byte[] b)
Overrides
FilterInputStream.read to update the progress listener after the read. |
int |
read(byte[] b,
int off,
int len)
Overrides
FilterInputStream.read to update the progress listener after the read. |
void |
reset()
Overrides
FilterInputStream.reset
to reset the progress monitor as well as the stream. |
ProgressInputStream |
setSuppressFailureOnClose(boolean suppressFailureOnClose)
Sets suppressions of IOExceptions that occur when closing an InputStream.
|
long |
skip(long n)
Overrides
FilterInputStream.skip to update the progress listener after the skip. |
protected boolean |
updateProgress(long bytesSoFar,
long size)
Called whenever new data has been read.
|
available, mark, markSupportedpublic ProgressInputStream(ProgressListener progressListener, InputStream in, long size)
progressListener - progress listener to report progress to and query for cancellingin - The input stream to be monitored.size - expected total size of the InputStream. May be 0 if unknown.public ProgressInputStream(ProgressListener progressListener, File file) throws FileNotFoundException
progressListener - progress listener to report progress to and query for cancellingfile - the file to read from.FileNotFoundExceptionpublic ProgressInputStream setSuppressFailureOnClose(boolean suppressFailureOnClose)
suppressFailureOnClose - true to suppress IOExceptions that occur when closing an InputStream.public int read()
throws IOException
FilterInputStream.read
to update the progress monitor after the read.read in class FilterInputStreamIOExceptionprotected boolean updateProgress(long bytesSoFar,
long size)
ProgressListener.setProgress(double) and returns true if the progress listener
requests the read be canceled.bytesSoFar - the number of bytes read so far.size - the total number of bytes to read, which may be 0 if unknown.public int read(byte[] b)
throws IOException
FilterInputStream.read to update the progress listener after the read.read in class FilterInputStreamIOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
FilterInputStream.read to update the progress listener after the read.read in class FilterInputStreamIOExceptionpublic long skip(long n)
throws IOException
FilterInputStream.skip to update the progress listener after the skip.skip in class FilterInputStreamIOExceptionpublic void close()
throws IOException
FilterInputStream.close
to close the progress monitor as well as the stream.close in interface Closeableclose in interface AutoCloseableclose in class FilterInputStreamIOExceptionpublic void reset()
throws IOException
FilterInputStream.reset
to reset the progress monitor as well as the stream.reset in class FilterInputStreamIOException