Here you can find the source of toString(@Nonnull ByteBuffer buf, int len)
@Nonnull public static String toString(@Nonnull ByteBuffer buf, int len)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; import java.util.Arrays; import javax.annotation.Nonnull; public class Main { @Nonnull public static String toString(@Nonnull ByteBuffer buf, int len) { byte[] b = new byte[Math.min(buf.remaining(), len)]; for (int i = 0; i < b.length; i++) b[i] = buf.get(buf.position() + i); return "[" + Arrays.toString(b) + "...(" + buf.remaining() + " bytes)]"; }// w w w . j av a 2s .c o m }