java.lang.Object
org.tentackle.update.CallbackReadableByteChannel
- All Implemented Interfaces:
Closeable,AutoCloseable,Channel,ReadableByteChannel
A
ReadableByteChannel with an optional callback lambda to show the progress.-
Constructor Summary
ConstructorsConstructorDescriptionCallbackReadableByteChannel(ReadableByteChannel channel, long expectedSize, Consumer<Double> progressConsumer) Creates a callback read channel. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intgetSize()Gets the number of bytes read so far.booleanisOpen()intread(ByteBuffer dst)
-
Constructor Details
-
CallbackReadableByteChannel
public CallbackReadableByteChannel(ReadableByteChannel channel, long expectedSize, Consumer<Double> progressConsumer) Creates a callback read channel.- Parameters:
channel- the channel to be wrappedexpectedSize- the expected size, negative if indefiniteprogressConsumer- the optional consumer receiving the progress from 0.0 to 1.0 (negative if indefinite), null if none
-
-
Method Details
-
read
- Specified by:
readin interfaceReadableByteChannel- Throws:
IOException
-
isOpen
public boolean isOpen() -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getSize
public int getSize()Gets the number of bytes read so far.- Returns:
- the size
-