- java.lang.Object
-
- org.tentackle.update.CallbackReadableByteChannel
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.nio.channels.Channel,java.nio.channels.ReadableByteChannel
public class CallbackReadableByteChannel extends java.lang.Object implements java.nio.channels.ReadableByteChannelAReadableByteChannelwith an optional callback lambda to show the progress.
-
-
Constructor Summary
Constructors Constructor Description CallbackReadableByteChannel(java.nio.channels.ReadableByteChannel channel, long expectedSize, java.util.function.Consumer<java.lang.Double> progressConsumer)Creates a callback read channel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()intgetSize()Gets the number of bytes read so far.booleanisOpen()intread(java.nio.ByteBuffer dst)
-
-
-
Constructor Detail
-
CallbackReadableByteChannel
public CallbackReadableByteChannel(java.nio.channels.ReadableByteChannel channel, long expectedSize, java.util.function.Consumer<java.lang.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 Detail
-
read
public int read(java.nio.ByteBuffer dst) throws java.io.IOException- Specified by:
readin interfacejava.nio.channels.ReadableByteChannel- Throws:
java.io.IOException
-
isOpen
public boolean isOpen()
- Specified by:
isOpenin interfacejava.nio.channels.Channel
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.nio.channels.Channel- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
getSize
public int getSize()
Gets the number of bytes read so far.- Returns:
- the size
-
-