List of utility methods to do ByteBuffer Read
byte | read(ByteBuffer buffer) read return buffer.get();
|
void | read(ByteBuffer dest, ByteBuffer src) read int srcRemaing = src.remaining(); if (srcRemaing == 0) { return; int remaining = dest.remaining(); if (remaining == 0) { return; if (remaining <= srcRemaing) { dest.put(src.array(), src.position(), remaining); src.position(src.position() + remaining); } else { dest.put(src.array(), src.position(), srcRemaing); src.position(src.limit()); |
ByteBuffer | read(ByteBuffer src, int len) Read len bytes from src buffer if (len > src.remaining()) throw new BufferOverflowException(); ByteBuffer result = ByteBuffer.allocate(len); int n = src.remaining(); for (int i = 0; i < n; i++) { result.put(src.get()); return result; ... |
byte[] | read(final ByteBuffer buffer, final byte marker) read final byte[] source = buffer.array(); final int start = buffer.position(); int index = start; while (index < source.length && source[index] != marker) { index++; buffer.position(index + 1); final int size = index - start; ... |
int | read(SocketChannel p_channel, SSLEngine p_sslEngine, ByteBuffer p_inAppBuf, ByteBuffer p_inNetBuf) The buffer The buffer final int l_iBytesBefore; final int l_iBytesAfter; assert p_inAppBuf.limit() == p_inAppBuf.capacity(); assert p_inNetBuf.limit() == p_inNetBuf.capacity(); l_iBytesBefore = p_inAppBuf.position(); while (true) { final int l_iRead; final SSLEngineResult l_res; ... |
byte[] | readableBytes(ByteBuffer buffer) Return a array of bytes that holds all the readable data of the ByteBuffer . byte[] readBytes = new byte[buffer.remaining()]; System.arraycopy(buffer.array(), buffer.arrayOffset() + buffer.position(), readBytes, 0, readBytes.length); return readBytes; |
String | readAlexString(ByteBuffer buffer) read Alex String int count = buffer.get() & 0xfff; byte bytes[] = new byte[count]; buffer.get(bytes, 0, count); return new String(bytes); |
byte[] | readAllLeftBytes(ByteBuffer buffer) read All Left Bytes byte[] result = new byte[buffer.remaining()]; buffer.get(result); return result; |
String | readASCII(ByteBuffer buffer) read ASCII StringBuilder sb = new StringBuilder(); int cc; cc = buffer.get() & 0xff; while (cc != 0) { if (cc == -1) { throw new IOException("Unexpected EOF"); sb.append((char) cc); ... |
String | readAsciiString(MappedByteBuffer buffer, int pos, int length) read Ascii String byte[] target = new byte[length]; getBytes(buffer, pos, target); return new String(target); |