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:
java.io.Closeable,java.lang.AutoCloseable
class NotifyingInputStream extends CountingInputStream
Input stream which notifies a listener about its progress.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.function.Consumer<java.lang.Long>downloadListener(package private) static intMAX_NOTIFICATIONS(package private) static intMIN_CHUNK_SIZEprivate longnextUpdateSize(package private) static intUNKNOWN_CHUNK_SIZEprivate longupdateChunkSize
-
Constructor Summary
Constructors Constructor Description NotifyingInputStream(java.io.InputStream inputStream, long totalSize, java.util.function.Consumer<java.lang.Long> downloadListener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private longcalculateChunkSize(long totalSize)private voidhandleRead(long result)private voidnotifyListener()intread()intread(byte[] b, int off, int len)-
Methods inherited from class net.adoptopenjdk.icedteaweb.resources.downloader.CountingInputStream
mark, numBytesRead, reset, skip
-
-
-
-
Field Detail
-
UNKNOWN_CHUNK_SIZE
static final int UNKNOWN_CHUNK_SIZE
- See Also:
- Constant Field Values
-
MIN_CHUNK_SIZE
static final int MIN_CHUNK_SIZE
- See Also:
- Constant Field Values
-
MAX_NOTIFICATIONS
static final int MAX_NOTIFICATIONS
- See Also:
- Constant Field Values
-
downloadListener
private final java.util.function.Consumer<java.lang.Long> downloadListener
-
updateChunkSize
private final long updateChunkSize
-
nextUpdateSize
private long nextUpdateSize
-
-
Method Detail
-
calculateChunkSize
private long calculateChunkSize(long totalSize)
-
read
public int read() throws java.io.IOException- Overrides:
readin classCountingInputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Overrides:
readin classCountingInputStream- Throws:
java.io.IOException
-
handleRead
private void handleRead(long result)
-
notifyListener
private void notifyListener()
-
-