List of utility methods to do ReadableByteChannel Read
int | readAll(ReadableByteChannel ch, ByteBuffer dst) Read channel until dst has remaining or eof. int count = 0; while (dst.hasRemaining()) { int rc = ch.read(dst); if (rc == -1) { if (count > 0) { return count; return -1; ... |
boolean | readAllBytesOrNone(ReadableByteChannel channel, ByteBuffer buffer, int numBytes) read All Bytes Or None buffer.rewind(); buffer.limit(numBytes); int totalBytesRead = 0; int bytesRead = channel.read(buffer); if (bytesRead <= 0) { return false; totalBytesRead += bytesRead; ... |
int | readAnerisHeader(ReadableByteChannel from, ByteBuffer buffer) Reads a header from the given channel connected to the Aneris service using the provided buffer. int headerLength = 0; int trialNo = 1; do { buffer.position(headerLength); headerLength++; buffer.limit(headerLength); while (buffer.hasRemaining()) { int bytesRead = from.read(buffer); ... |
void | readBuffer(ReadableByteChannel chan, ByteBuffer buf) Read a buffer completely from a channel. while (buf.hasRemaining()) {
chan.read(buf);
|
char[] | readCharArray(ReadableByteChannel channel, ByteBuffer buffer, char[] charArray) read Char Array buffer.clear(); int charsLeft = charArray.length; int maxSize = buffer.capacity() / 2; int offset = 0; while (charsLeft > 0) { if (charsLeft > maxSize) { buffer.limit(maxSize * 2); charsLeft -= maxSize; ... |
String | readFromAnerisChannel(ReadableByteChannel chan, ByteBuffer buffer) Reads the next Aneris message from this channel and returns it in String form. int nbBytes = readAnerisHeader(chan, buffer); if (nbBytes != ERROR_HEADER_INT) { buffer.position(0); buffer.limit(nbBytes); int trialNo = 1; while (buffer.hasRemaining()) { int bytesRead = chan.read(buffer); if (bytesRead == 0) { ... |
int | readFromChannel(ReadableByteChannel channel, ByteBuffer buffer) read From Channel int rem = buffer.position(); while (channel.read(buffer) != -1 && buffer.hasRemaining()) ; return buffer.position() - rem; |
void | readFull(ReadableByteChannel ch, ByteBuffer dst) read Full int read = 0; do { read = ch.read(dst); } while (-1 != read && dst.remaining() > 0); |
void | readFully(final ReadableByteChannel channel, final ByteBuffer buf) read Fully readFully(channel, buf, buf.remaining()); |
int | readFully(final ReadableByteChannel channel, final ByteBuffer buf) read Fully return readFully(channel, buf, buf.remaining());
|