@Test public void testDeserializeStringLeadingWhitespace() { String string = Random.getString().trim(); int numWhiteSpaces = Random.getScaleCount(); string = Strings.padStart(string, string.length() + numWhiteSpaces, ' '); ByteBuffer bytes = ByteBuffer .wrap(string.getBytes(StandardCharsets.UTF_8)); String string2 = ByteBuffers.getString(bytes, StandardCharsets.UTF_8); Assert.assertEquals(string, string2); }
public static String getString(ByteBuffer buffer) { return getString(buffer, StandardCharsets.UTF_8); }
ByteBuffers { public static String getString(ByteBuffer buffer) { return getString(buffer, StandardCharsets.UTF_8); } }
ByteBuffers { public static String getString(ByteBuffer buffer) { return getString(buffer, StandardCharsets.UTF_8); }  }
ByteBuffers { public static String getString(ByteBuffer buffer) { return getString(buffer, StandardCharsets.UTF_8); }  static ByteBuffer asReadOnlyBuffer(ByteBuffer source); static ByteBuffer clone(ByteBuffer buffer); static void copyAndRewindSource(ByteBuffer source,
            ByteBuffer destination); static ByteBuffer decodeFromHex(String hex); static String encodeAsHex(ByteBuffer bytes); static String encodeAsHexString(ByteBuffer buffer); static ByteBuffer expand(ByteBuffer destination, ByteBuffer source); static ByteBuffer expandInt(ByteBuffer destination, int value); static ByteBuffer fromString(String string); static ByteBuffer get(ByteBuffer buffer, int length); static boolean getBoolean(ByteBuffer buffer); static T getEnum(ByteBuffer buffer,
            Class<T> clazz); static ByteBuffer getRemaining(ByteBuffer buffer); static String getString(ByteBuffer buffer); static String getString(ByteBuffer buffer, Charset charset); static ByteBuffer nullByteBuffer(); static void putString(String source, ByteBuffer destination); static ByteBuffer rewind(ByteBuffer buffer); static ByteBuffer slice(ByteBuffer buffer, int length); static ByteBuffer slice(ByteBuffer buffer, int position,
            int length); static byte[] toByteArray(ByteBuffer buffer); static CharBuffer toCharBuffer(ByteBuffer buffer); static CharBuffer toCharBuffer(ByteBuffer buffer, Charset charset); }
ByteBuffers { public static String getString(ByteBuffer buffer) { return getString(buffer, StandardCharsets.UTF_8); }  static ByteBuffer asReadOnlyBuffer(ByteBuffer source); static ByteBuffer clone(ByteBuffer buffer); static void copyAndRewindSource(ByteBuffer source,
            ByteBuffer destination); static ByteBuffer decodeFromHex(String hex); static String encodeAsHex(ByteBuffer bytes); static String encodeAsHexString(ByteBuffer buffer); static ByteBuffer expand(ByteBuffer destination, ByteBuffer source); static ByteBuffer expandInt(ByteBuffer destination, int value); static ByteBuffer fromString(String string); static ByteBuffer get(ByteBuffer buffer, int length); static boolean getBoolean(ByteBuffer buffer); static T getEnum(ByteBuffer buffer,
            Class<T> clazz); static ByteBuffer getRemaining(ByteBuffer buffer); static String getString(ByteBuffer buffer); static String getString(ByteBuffer buffer, Charset charset); static ByteBuffer nullByteBuffer(); static void putString(String source, ByteBuffer destination); static ByteBuffer rewind(ByteBuffer buffer); static ByteBuffer slice(ByteBuffer buffer, int length); static ByteBuffer slice(ByteBuffer buffer, int position,
            int length); static byte[] toByteArray(ByteBuffer buffer); static CharBuffer toCharBuffer(ByteBuffer buffer); static CharBuffer toCharBuffer(ByteBuffer buffer, Charset charset);  }