Java ByteBuffer Read contentOfUnreadBuffer(final ByteBuffer buffer)

Here you can find the source of contentOfUnreadBuffer(final ByteBuffer buffer)

Description

content of unread byte buffer, hex representation using ByteBuffer#getInt()

License

Open Source License

Parameter

Parameter Description
buffer a parameter

Declaration

public static final String contentOfUnreadBuffer(final ByteBuffer buffer) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.nio.ByteBuffer;

public class Main {
    /**/*from  w  ww.j  a v a  2  s. com*/
     * content of unread byte buffer, hex representation using {@link ByteBuffer#getInt()}
     * @param buffer
     * @return
     */
    public static final String contentOfUnreadBuffer(final ByteBuffer buffer) {
        int position = buffer.position();
        int limit = buffer.limit();

        StringBuffer sb = new StringBuffer();
        while (buffer.hasRemaining()) {
            sb.append(Integer.toHexString(buffer.getInt()));
        }

        // insist no side effect
        buffer.position(position);
        buffer.limit(limit);

        return sb.toString();
    }
}

Related

  1. assertReadyForFreshRead(ByteBuffer b)
  2. c_read(Channel fd, ByteBuffer buffer, int count)
  3. checkNotReadOnly(ByteBuffer buffer)
  4. enlargeThreadLocalByteBuffer()
  5. parseEsInfo(ByteBuffer read)
  6. read(@Nonnull final FileChannel src, @Nonnull final ByteBuffer dst, @Nonnegative final long position)
  7. read(ByteBuffer b)