Java tutorial
import java.nio.CharBuffer; public class MainClass { public static void main(String[] argv) throws Exception { char[] chars = new char[60]; CharBuffer cb = CharBuffer.wrap(chars, 12, 42); println(cb); cb.put("This is a test String"); cb.flip(); println(cb); cb.clear(); cb.put("Foobar"); println(cb); for (int i = 0; i < 20; i++) { System.out.println("[" + i + "] = " + chars[i]); } } private static void println(CharBuffer cb) { System.out.println("pos=" + cb.position() + ", limit=" + cb.limit() + ", capacity=" + cb.capacity() + ", arrayOffset=" + cb.arrayOffset()); } } /* */