Add javadocs to StringUtils.fromUtf8. (#11881)

They clarify that the methods advance the position of the buffer.
This commit is contained in:
Gian Merlino 2021-11-05 15:27:24 -07:00 committed by GitHub
parent 8971056763
commit 1c12dd97dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -88,6 +88,10 @@ public class StringUtils
}
}
/**
* Decodes a UTF-8 String from {@code numBytes} bytes starting at the current position of a buffer.
* Advances the position of the buffer by {@code numBytes}.
*/
public static String fromUtf8(final ByteBuffer buffer, final int numBytes)
{
final byte[] bytes = new byte[numBytes];
@ -95,6 +99,10 @@ public class StringUtils
return fromUtf8(bytes);
}
/**
* Decodes a UTF-8 string from the remaining bytes of a buffer.
* Advances the position of the buffer by {@link ByteBuffer#remaining()}.
*/
public static String fromUtf8(final ByteBuffer buffer)
{
return StringUtils.fromUtf8(buffer, buffer.remaining());