Class ByteBuffers


  • public class ByteBuffers
    extends Object
    • 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 read
        destination - ByteBuffer into which bytes are written
        Returns:
        number of bytes copied, i.e. source.remaining() or destination.remaining(), whatever is less.
      • fill

        public static int fill​(ReadableByteChannel source,
                               ByteBuffer buffer)
                        throws IOException
        Fills the given buffer by reading from the given source until either reaching EOF or buffer has no more remaining space.
        Parameters:
        source - The channel to read from
        buffer - The buffer to fill
        Returns:
        Number of bytes read. Will only be less than remaining space in buffer if reaching EOF.
        Throws:
        IOException - In case of I/O errors