List of utility methods to do ByteBuffer to String
String | string(ByteBuffer buffer) Returns a string in the buffer. byte[] bytes = new byte[buffer.remaining()]; buffer.get(bytes); return new String(bytes, StandardCharsets.UTF_8); |
String | string(ByteBuffer buffer) Decode a String representation. return string(buffer, UTF_8);
|
String | string(ByteBuffer buffer, int position, int length, Charset charset) Decode a String representation. ByteBuffer copy = buffer.duplicate();
copy.position(position);
copy.limit(copy.position() + length);
return string(copy, charset);
|
String | string(ByteBuffer bytes) string if (bytes == null) { return null; return string(bytes.array(), bytes.arrayOffset() + bytes.position(), bytes.remaining(), UTF8_ENCODING); |
String | toString(@Nonnull ByteBuffer buf, int len) to String byte[] b = new byte[Math.min(buf.remaining(), len)]; for (int i = 0; i < b.length; i++) b[i] = buf.get(buf.position() + i); return "[" + Arrays.toString(b) + "...(" + buf.remaining() + " bytes)]"; |
String | toString(ByteBuffer b, String separator) to String StringBuilder s = new StringBuilder(); for (int i = b.position(); i < b.limit(); i++) { if (i > b.position()) s.append(separator); byte c = b.get(i); if (c >= 0) s.append(c); else ... |
String | toString(ByteBuffer bb) to String StringBuilder sb = new StringBuilder(); while (bb.hasRemaining()) { sb.append((char) bb.get()); return sb.toString(); |
String | toString(ByteBuffer buf) to String StringBuilder sb = new StringBuilder(); StringBuilder hb = new StringBuilder(); byte b; buf.mark(); while (buf.hasRemaining()) { b = buf.get(); hb.append(String.format("%02X ", b)); sb.append(String.format("%c", (char) b)); ... |
String | toString(ByteBuffer buf, int len) Converts the first len bytes from ByteBuffer buf into a String. byte[] bytes = new byte[len]; buf.get(bytes); return new String(bytes); |
String | toString(ByteBuffer buffer) to String byte bytes[] = new byte[buffer.remaining()]; buffer.get(bytes); return new String(bytes); |