import java.io.*; import java.nio.*; import java.nio.ByteBuffer; public class GetChBuffer { public static final int size = 1024; public static void main(String[] args) throws Exception { ByteBuffer bytebuf = ByteBuffer.allocate(size); bytebuf.asCharBuffer().put("Bharat Singh"); char c; System.out.print("Character available in buffer : "); while ((c = bytebuf.getChar()) != 0) { System.out.print(c); } } }