Here you can find the source of println(String string, ByteBuffer buffer)
public static void println(String string, ByteBuffer buffer)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; public class Main { public static void println(String string, ByteBuffer buffer) { if (buffer == null || !buffer.hasRemaining()) return; byte[] bytes = new byte[buffer.remaining()]; buffer.get(bytes);/*from w ww . ja va 2s . co m*/ buffer.flip(); println(string, bytes); } public static void println(String string, byte... bytes) { if (bytes == null) return; StringBuilder sb = new StringBuilder(); if (string != null) sb.append(string); sb.append(bytes.length).append(".["); boolean last = false; for (byte b : bytes) { if (last) sb.append(','); int v = b & 0xff; if (v < 16) sb.append('0'); sb.append(Integer.toHexString(v)); last = true; } sb.append(']'); (System.out).println(sb); } }