Here you can find the source of toString(ByteBuffer buffer)
Parameter | Description |
---|---|
buffer | The buffer. |
public static String toString(ByteBuffer buffer)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { /**//from www . jav a 2s .c o m * Converts the contents of the specified byte buffer to a string, which is * formatted similarly to the output of the {@link Arrays#toString()} * method. * @param buffer The buffer. * @return The string. */ public static String toString(ByteBuffer buffer) { StringBuilder builder = new StringBuilder("["); for (int i = 0; i < buffer.limit(); i++) { String hex = Integer.toHexString(buffer.get(i) & 0xFF).toUpperCase(); if (hex.length() == 1) hex = "0" + hex; builder.append("0x").append(hex); if (i != buffer.limit() - 1) { builder.append(", "); } } builder.append("]"); return builder.toString(); } }