- java.lang.Object
-
- org.cryptomator.cryptolib.common.ByteBuffers
-
public class ByteBuffers extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcopy(ByteBuffer source, ByteBuffer destination)Copies as many bytes as possible from the given source to the destination buffer.static intfill(ReadableByteChannel source, ByteBuffer buffer)Fills the givenbufferby reading from the given source until either reaching EOF orbufferhas no moreremaining space.
-
-
-
Method Detail
-
copy
public static int copy(ByteBuffer source, ByteBuffer destination)
Copies as many bytes as possible from the given source to the destination buffer. The position of both buffers will be incremented by as many bytes as have been copied.- Parameters:
source- ByteBuffer from which bytes are readdestination- ByteBuffer into which bytes are written- Returns:
- number of bytes copied, i.e.
source.remaining()ordestination.remaining(), whatever is less.
-
fill
public static int fill(ReadableByteChannel source, ByteBuffer buffer) throws IOException
Fills the givenbufferby reading from the given source until either reaching EOF orbufferhas no moreremaining space.- Parameters:
source- The channel to read frombuffer- The buffer to fill- Returns:
- Number of bytes read. Will only be less than remaining space in
bufferif reaching EOF. - Throws:
IOException- In case of I/O errors
-
-