Here you can find the source of byteBufferToString(ByteBuffer buffer)
public static String byteBufferToString(ByteBuffer buffer)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { public static String byteBufferToString(ByteBuffer buffer) { StringBuffer sb = new StringBuffer("["); if (buffer.hasRemaining()) sb.append(buffer.get());/*from w ww . j a v a 2 s . c o m*/ while (buffer.hasRemaining()) sb.append(", ").append(buffer.get()); sb.append("]"); buffer.rewind(); return new String(sb); } }