Here you can find the source of dump(ByteBuffer buffer, int pos, int limit)
public static String dump(ByteBuffer buffer, int pos, int limit)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { public static String dump(ByteBuffer buffer, int pos, int limit) { int oldpos = buffer.position(); int oldlimit = buffer.limit(); buffer.limit(limit).position(pos); StringBuilder builder = new StringBuilder("["); for (int idx = buffer.position(); idx < buffer.limit(); ++idx) { builder.append(buffer.get(idx)); builder.append(','); }/*from w ww .j a v a 2 s . c o m*/ builder.append(']'); buffer.limit(oldlimit).position(oldpos); return builder.toString(); } }