Package de.murmelmeister.murmelapi.utils
Class BufferUtils
java.lang.Object
de.murmelmeister.murmelapi.utils.BufferUtils
Utility class for reading and writing UTF-8 strings to/from ByteBuffer.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
BufferUtils
public BufferUtils()
-
-
Method Details
-
encodeUTF
Encodes the given string into a UTF-8 byte array prefixed with its length.The resulting byte array begins with a 4-byte integer representing the length of the UTF-8 encoded string, followed by the UTF-8 encoded bytes of the string.
- Parameters:
value- The string to encode- Returns:
- A byte array containing the UTF-8 encoded string prefixed with its length
-
decodeUTF
Decodes a UTF-8 encoded string from the given byte array.The byte array is expected to start with a 4-byte integer that specifies the length of the UTF-8 encoded string, followed by the string's byte representation.
- Parameters:
bytes- The byte array containing the UTF-8 encoded string, prefixed with its length- Returns:
- The decoded string
-