Class NotifyingInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
net.adoptopenjdk.icedteaweb.resources.downloader.CountingInputStream
net.adoptopenjdk.icedteaweb.resources.downloader.NotifyingInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
Input stream which notifies a listener about its progress.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final int(package private) static final intprivate long(package private) static final intprivate final longFields inherited from class FilterInputStream
in -
Constructor Summary
ConstructorsConstructorDescriptionNotifyingInputStream(InputStream inputStream, long totalSize, Consumer<Long> downloadListener) -
Method Summary
Modifier and TypeMethodDescriptionprivate longcalculateChunkSize(long totalSize) private voidhandleRead(long result) private voidintread()intread(byte[] b, int off, int len) Methods inherited from class CountingInputStream
mark, numBytesRead, reset, skipMethods inherited from class FilterInputStream
available, close, markSupported, readMethods inherited from class InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
UNKNOWN_CHUNK_SIZE
static final int UNKNOWN_CHUNK_SIZE- See Also:
-
MIN_CHUNK_SIZE
static final int MIN_CHUNK_SIZE- See Also:
-
MAX_NOTIFICATIONS
static final int MAX_NOTIFICATIONS- See Also:
-
downloadListener
-
updateChunkSize
private final long updateChunkSize -
nextUpdateSize
private long nextUpdateSize
-
-
Constructor Details
-
NotifyingInputStream
public NotifyingInputStream(InputStream inputStream, long totalSize, Consumer<Long> downloadListener)
-
-
Method Details
-
calculateChunkSize
private long calculateChunkSize(long totalSize) -
read
- Overrides:
readin classCountingInputStream- Throws:
IOException
-
read
- Overrides:
readin classCountingInputStream- Throws:
IOException
-
handleRead
private void handleRead(long result) -
notifyListener
private void notifyListener()
-