Package glide.utils
Class BufferUtils
- java.lang.Object
-
- glide.utils.BufferUtils
-
public final class BufferUtils extends java.lang.ObjectUtility methods for efficient ByteBuffer operations. Provides optimized methods for common buffer manipulations to reduce allocations and improve performance.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringdecodeUtf8(java.nio.ByteBuffer buffer)Decodes all remaining bytes in the ByteBuffer as a UTF-8 string.static java.lang.StringdecodeUtf8(java.nio.ByteBuffer buffer, int length)Decodes a UTF-8 string directly from a ByteBuffer without creating intermediate byte arrays.
-
-
-
Method Detail
-
decodeUtf8
public static java.lang.String decodeUtf8(java.nio.ByteBuffer buffer, int length)Decodes a UTF-8 string directly from a ByteBuffer without creating intermediate byte arrays. This method temporarily adjusts the buffer's limit to decode only the specified length of bytes, then restores the original limit.- Parameters:
buffer- The ByteBuffer to decode from. Position will be advanced by length bytes.length- The number of bytes to decode- Returns:
- The decoded UTF-8 string
- Throws:
java.nio.charset.CharacterCodingException- if the bytes are not valid UTF-8
-
decodeUtf8
public static java.lang.String decodeUtf8(java.nio.ByteBuffer buffer)
Decodes all remaining bytes in the ByteBuffer as a UTF-8 string.- Parameters:
buffer- The ByteBuffer to decode from. Position will be advanced to the limit.- Returns:
- The decoded UTF-8 string
- Throws:
java.nio.charset.CharacterCodingException- if the bytes are not valid UTF-8
-
-