List of utility methods to do ByteBuffer to String
String | asStr(ByteBuffer buff) as Str return new String(buff.array(), buff.arrayOffset() + buff.position(), buff.limit()); |
String | asString(ByteBuffer buffer, int length) Returns the contents of a buffer as a string, converting ASCII characters in the buffer, into unicode string characters. char[] chars = new char[length]; for (int i = 0; i < length; i++) { chars[i] = (char) buffer.get(i); return String.valueOf(chars); |
String | asString(final ByteBuffer buffer) as String final byte[] bytes = new byte[buffer.limit()]; buffer.get(bytes); return new String(bytes, "US-ASCII"); |
String | asString(Map as String if (headers == null) { return null; Iterator<Entry<ByteBuffer, ByteBuffer>> i = headers.entrySet().iterator(); if (!i.hasNext()) { return "{}"; StringBuilder sb = new StringBuilder(); ... |
String | bbToString(ByteBuffer bb) bb To String return new String(bbToArray(bb)); |
String | buffer2String(ByteBuffer buff, String charsetName) buffer String return Charset.forName(charsetName).decode(buff).toString();
|
String | bufferToString(ByteBuffer buf) buffer To String try { boolean isString = true; byte[] arr = buf.array(); for (int i = 0; i < buf.remaining(); i++) { byte c = arr[i]; if (c <= 127 || ((c & 0xC0) == 0x80) || ((c & 0xE0) == 0xC0)) continue; isString = false; ... |
String | bufferToString(ByteBuffer buf) buffer To String return new String(buf.array(), StandardCharsets.UTF_8); |
String | bufferToString(ByteBuffer buff) buffer To String Charset charset = Charset.forName("UTF-8"); CharsetDecoder decoder = charset.newDecoder(); String message = ""; try { message = decoder.decode(buff).toString(); } catch (Exception e) { message = e.getMessage(); return message; |
String | bufferToString(ByteBuffer buffer) buffer To String if (buffer.hasArray()) { return new String(buffer.array(), buffer.arrayOffset(), buffer.remaining()); } else { int oldPos = buffer.position(); byte[] bytes = new byte[buffer.remaining()]; buffer.get(bytes); buffer.position(oldPos); return new String(bytes); ... |