Here you can find the source of byteBufferToString(ByteBuffer buffer)
Parameter | Description |
---|---|
buffer | - Byte Data Buffer |
public static String byteBufferToString(ByteBuffer buffer)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; public class Main { /**/*from ww w. j a va2 s . com*/ * Takes a ByteBuffer in read mode and converts it to a * comma separated string of Hex encoded bytes. This is a * read only operation. When this operation is complete the * ByteBuffer will be rewound. * @param buffer - Byte Data Buffer * @return A string representation of the data */ public static String byteBufferToString(ByteBuffer buffer) { StringBuilder builder = new StringBuilder(buffer.remaining() * 2); while (buffer.hasRemaining()) { String formatted = String.format("%02X", Byte.valueOf(buffer.get())); builder.append(formatted).append(','); } buffer.rewind(); return builder.toString(); } }