Class ByteBufferUtils


  • public final class ByteBufferUtils
    extends Object
    Helper methods which reduce boiler-plate code for ByteBuffer
    • Method Detail

      • putString

        public static void putString​(ByteBuffer buffer,
                                     String s)
        Puts the given string as UTF-8 into the buffer.
        Parameters:
        buffer - The buffer to append the string to.
        s - The string to put.
      • getString

        public static String getString​(ByteBuffer buffer,
                                       int length)
        Gets a UTF-8 string of the given length in bytes.
        Parameters:
        buffer - The buffer to get from.
        length - The amount of bytes to consume.
        Returns:
        The read string.
      • getBytes

        public static byte[] getBytes​(ByteBuffer buffer,
                                      int length)
        Gets the next length bytes as a byte array.
        Parameters:
        buffer - The buffer to get from.
        length - The amount of bytes to consume.
        Returns:
        The read byte array.