List of utility methods to do ByteBuffer Decode
CharBuffer | bytesToChars(CharsetDecoder decoder, ByteBuffer bytes, CharBuffer chars) Convert byte buffer's content into characters. assert decoder.malformedInputAction() == CodingErrorAction.REPORT; chars = clearAndEnsureCapacity(chars, (int) (bytes.remaining() * decoder.maxCharsPerByte())); bytes.mark(); decoder.reset(); CoderResult cr = decoder.decode(bytes, chars, true); if (cr.isError()) { bytes.reset(); try { ... |
String | decode(byte firstByte, ByteBuffer buffer, String charset) decode int lenOrValue = firstByte & OB_VARCHAR_LEN_MASK; int strLen = 0; if (lenOrValue <= OB_MAX_1B_STR_LEN) { strLen = lenOrValue; } else { for (int n = 0; n < lenOrValue - OB_MAX_1B_STR_LEN; n++) { strLen |= ((buffer.get() & 0xffl) << (n << 3)); byte[] ret = new byte[strLen]; buffer.get(ret); try { return new String(ret, charset); } catch (UnsupportedEncodingException e) { return ""; |
String | decode(ByteBuffer bb) decode return charset.decode(bb).toString();
|
String | decode(ByteBuffer bb, CharsetDecoder decoder) decode CharBuffer cb = CharBuffer.allocate(128); CoderResult result = decoder.decode((ByteBuffer) bb.flip(), cb, true ); if (result.isError()) { throw new IllegalArgumentException("Malformed UTF-8!"); return ((CharBuffer) cb.flip()).toString(); |
String | decode(Charset charset, ByteBuffer buffer) decode CharBuffer cb = charset.decode(buffer);
return cb.toString();
|
void | decode(CharsetDecoder decoder, ByteBuffer src, CharBuffer dst) decode try { CoderResult cr = decoder.decode(src, dst, true); if (!cr.isUnderflow()) { cr.throwException(); cr = decoder.flush(dst); if (!cr.isUnderflow()) { cr.throwException(); ... |
CharBuffer | decode(String charsetName, ByteBuffer byteBuffer) decode try { CharsetDecoder charsetDecoder = getCharsetDecoder(charsetName); return charsetDecoder.decode(byteBuffer); } catch (CharacterCodingException cce) { throw new Error(cce); |
void | decodeAlign(ByteBuffer buf) decode Align final int pos = buf.position(); final int newPos = aligned(pos); if (buf.limit() < newPos) throw new BufferUnderflowException(); buf.position(newPos); |
String | decodeASCII(ByteBuffer buffer, int length, int offset) decode ASCII char[] chars = new char[length]; for (int i = 0; i < length; i++) chars[i] = (char) buffer.get(offset + i); return new String(chars); |
String | decodeBuffer(ByteBuffer buffer, String charsetName) decode Buffer byte[] bytes = new byte[buffer.limit()]; buffer.get(bytes); try { return new String(bytes, charsetName); } catch (UnsupportedEncodingException e) { return new String(bytes); |