List of utility methods to do ByteBuffer to String
String | getString(ByteBuffer in, int maxLength) Read a string from the buffer. int l = in.getInt(); if (maxLength > 0 && l > maxLength) throw new BufferOverflowException(); byte[] b = new byte[l]; try { in.get(b); return new String(b, "ISO-8859-1"); } catch (BufferUnderflowException bue) { ... |
String | getString(final ByteBuffer buffer) Reads a String from a ByteBuffer. int length = buffer.getInt(); char[] chBuffer = new char[length]; for (int i = 0; i < length; i++) { chBuffer[i] = buffer.getChar(); return new String(chBuffer); |
String | getString(final ByteBuffer buffer, final int offset, final int length, final Charset encoding) Reads bytes from a ByteBuffer as if they were encoded in the specified CharSet. final byte[] b = new byte[length]; buffer.position(buffer.position() + offset); buffer.get(b); return new String(b, 0, length, encoding); |
String | getString(java.nio.ByteBuffer buffer, int offset, int len) get String String s = ""; if (null != buffer && buffer.capacity() >= offset + len) { byte[] dest = new byte[len]; buffer.position(offset); buffer.get(dest, 0, len); s = new String(dest).trim(); return s; ... |
String | getStringA(ByteBuffer byteBuffer, int length) get String A byte[] dst = getBytes(byteBuffer, length); return new String(dst); |
String | getStringDTrimmed(ByteBuffer byteBuffer, int length) get String D Trimmed return getStringD(byteBuffer, length).trim();
|
String | getStringFromBuffer(ByteBuffer buf, int len) get String From Buffer byte[] bytes = new byte[len]; buf.get(bytes); return esc0(new String(bytes)); |
String | getStringFromBuffer(ByteBuffer buffer, int length) get String From Buffer char[] arr = new char[length]; for (int i = 0; i < length; i++) { arr[i] = buffer.getChar(); return new String(arr); |
String | getStringFromByteBuffer(ByteBuffer bb) Returns a String representation of a ByteBuffer. StringBuilder message = new StringBuilder(); int bytes; while (true) { try { bytes = bb.get(); message.append("\\x" + String.format("%02x", bytes & 0xff)); } catch (Exception e) { break; ... |
String | getStringFromByteBuffer(ByteBuffer data) string from ByteBuffer return new String(data.array(), ENCODING); |