Package net.sf.basedb.util
Class ProgressInputStream
java.lang.Object
java.io.InputStream
net.sf.basedb.util.InputStreamTracker
net.sf.basedb.util.ProgressInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
Input stream wrapper that calls a progress reporter at regular
intervals. The default interval is 1MB of processed data. The
default progress message is simply to write the number of bytes
processed. If a different message is required the
progressReport(String)
method should be overridden.- Since:
- 3.9
- Author:
- nicklas
-
Nested Class Summary
Nested classes/interfaces inherited from class net.sf.basedb.util.InputStreamTracker
InputStreamTracker.CurvedScaleFactor, InputStreamTracker.IdentityScaleFactor, InputStreamTracker.LinearScaleFactor, InputStreamTracker.ScaleFactor
-
Field Summary
Modifier and TypeFieldDescriptionprotected final long
protected long
protected final AbsoluteProgressReporter
-
Constructor Summary
ConstructorDescriptionProgressInputStream
(InputStream in, AbsoluteProgressReporter progress) Create a new input stream using the default 1MB interval.ProgressInputStream
(InputStream in, AbsoluteProgressReporter progress, long interval) Create a new input stream using the specified interval. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
progressReport
(String message) Send a progress report with the given message.int
read
(byte[] b, int off, int len) Methods inherited from class net.sf.basedb.util.InputStreamTracker
available, close, getNumRead, mark, markSupported, read, read, reset, skip
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
progress
-
interval
protected final long interval -
nextProgress
protected long nextProgress
-
-
Constructor Details
-
ProgressInputStream
Create a new input stream using the default 1MB interval. -
ProgressInputStream
Create a new input stream using the specified interval.
-
-
Method Details
-
read
- Overrides:
read
in classInputStreamTracker
- Throws:
IOException
-
progressReport
Send a progress report with the given message. This method is called automatically at the given intervals. The default message is the number of bytes read so far (formatted as a string withValues.formatBytes(Long, int)
). Subclasses may override this method to generate a different message.
-