Java Utililty Methods ByteBuffer Read

List of utility methods to do ByteBuffer Read

  1. HOME
  2. Java
  3. B
  4. ByteBuffer Read

Description

The list of methods to do ByteBuffer Read are organized into topic(s).

Method

void assertReadyForFreshRead(ByteBuffer b)
Ensure that a buffer is prepared for reading from the beginning.
assert (b.limit() != 0); 
assert (b.position() == 0); 
int c_read(Channel fd, ByteBuffer buffer, int count)
read
try {
 ReadableByteChannel rc = (ReadableByteChannel) fd;
 buffer = buffer.duplicate();
 buffer.limit(buffer.position() + count);
 return rc.read(buffer);
} catch (Exception e) {
 e.printStackTrace();
 return -1;
...
void checkNotReadOnly(ByteBuffer buffer)
check Not Read Only
if (buffer.isReadOnly()) {
 throw new ReadOnlyBufferException();
String contentOfUnreadBuffer(final ByteBuffer buffer)
content of unread byte buffer, hex representation using ByteBuffer#getInt()
int position = buffer.position();
int limit = buffer.limit();
StringBuffer sb = new StringBuffer();
while (buffer.hasRemaining()) {
 sb.append(Integer.toHexString(buffer.getInt()));
buffer.position(position);
buffer.limit(limit);
...
ByteBuffer enlargeThreadLocalByteBuffer()
Double the thread local buffer capacity.
TMP_BUFFER.set(ByteBuffer.allocate(TMP_BUFFER.get().capacity() * 2));
return TMP_BUFFER.get();
void parseEsInfo(ByteBuffer read)
parse Es Info
int read(@Nonnull final FileChannel src, @Nonnull final ByteBuffer dst, @Nonnegative final long position)
Read until dst buffer is filled or src channel is reached end.
int count = 0;
long offset = position;
while (dst.remaining() > 0) {
 int n = src.read(dst, offset);
 if (n == -1) {
 break;
 offset += n;
...
int read(ByteBuffer b)
read
int result = (b.get() & 0xFF);
return result;
void read(ByteBuffer bb, FileChannel ch)
read
bb.clear();
ch.read(bb);
bb.flip();
long read(ByteBuffer bb, int elementWidth)
read
final long value = readBE(bb, elementWidth);
if (bb.order() == ByteOrder.BIG_ENDIAN) {
 return value;
return swap(elementWidth, value);


AltStyle によって変換されたページ (->オリジナル) /