ByteBuffer to String - Java java.nio

Java examples for java.nio:ByteBuffer String

Description

ByteBuffer to String

Demo Code


//package com.java2s;
import java.nio.ByteBuffer;

public class Main {
    public static String toString(ByteBuffer bb) {
        StringBuilder sb = new StringBuilder();
        while (bb.hasRemaining()) {
            sb.append((char) bb.get());
        }// ww  w  . j av  a 2  s  .c o m
        return sb.toString();
    }
}

Related Tutorials