Here you can find the source of contentOfUnreadBuffer(final ByteBuffer buffer)
Parameter | Description |
---|---|
buffer | a parameter |
public static final String contentOfUnreadBuffer(final ByteBuffer buffer)
//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(); } }