Java tutorial
import java.io.*; import java.nio.CharBuffer; public class Main { public static void main(String[] args) { String s = "tutorial from java2s.com"; CharBuffer cb = CharBuffer.allocate(100); Reader reader = new StringReader(s); try { reader.read(cb); cb.flip(); // print the char buffer System.out.println(cb.toString()); reader.close(); } catch (IOException ex) { ex.printStackTrace(); } } }