List of utility methods to do ByteBuffer to String
String | convertBufferToString(ByteBuffer buffer) convert Buffer To String if (buffer.remaining() == 0) return ""; byte[] bytes = new byte[buffer.limit()]; buffer.get(bytes); return new String(bytes); |
String | decodeString(ByteBuffer bb) decode String return Charset.forName("UTF-8").decode(bb).toString(); |
String | decodeString(ByteBuffer buffer, String charset) Convert the bytes in a given buffer to a string, using a given charset. if (buffer == null) { return null; if (charset == null) { throw new IllegalArgumentException("charset"); try { return new String(buffer.array(), buffer.position(), buffer.limit() - buffer.position(), charset); ... |
String | decodeString(ByteBuffer src) decode String CharsetDecoder theDecoder = decoder.get(); theDecoder.reset(); final CharBuffer dst = CharBuffer.allocate((int) ((double) src.remaining() * theDecoder.maxCharsPerByte())); CoderResult cr = theDecoder.decode(src, dst, true); if (!cr.isUnderflow()) cr.throwException(); cr = theDecoder.flush(dst); if (!cr.isUnderflow()) ... |
String | getStr(ByteBuffer buff) read a String from a ByteBuffer that was written w/the putStr method short len = buff.getShort(); if (len == 0) { return null; } else { byte[] b = new byte[len]; buff.get(b); return new String(b); |
String | getString(@Nonnull final ByteBuffer src) get String final int size = src.getInt(); if (size == -1) { return null; final char[] array = new char[size]; for (int i = 0; i < size; i++) { array[i] = src.getChar(); return new String(array); |
String | getString(ByteBuffer bb) Inputs a string from a ByteBuffer. int size = bb.getShort(); char[] charBuffer = new char[size]; for (int i = 0; i < size; i++) { charBuffer[i] = bb.getChar(); return new String(charBuffer, 0, size); |
String | getString(ByteBuffer buf) Gets an RS2 string from the buffer. StringBuilder bldr = new StringBuilder(); char c; while ((c = (char) buf.get()) != 10) { bldr.append(c); return bldr.toString(); |
String | getString(ByteBuffer buf) get String int len = buf.getShort(); if (len == -1) return null; char[] cs = new char[len]; for (int i = 0; i < len; i++) { cs[i] = buf.getChar(); return new String(cs); ... |
String | getString(ByteBuffer buf) get String StringBuilder bldr = new StringBuilder(); int b; while ((b = (buf.get() & 0xFF)) != 0) { bldr.append((char) b); return bldr.toString(); |