Java tutorial
import java.nio.ByteBuffer; import java.nio.CharBuffer; public class Main { public static void main(String[] argv) throws Exception { ByteBuffer buf = ByteBuffer.allocate(100); CharBuffer cbuf = buf.asCharBuffer(); cbuf.put("a string"); int start = 2; // start is relative to cbuf's current position int end = 5; CharSequence sub = cbuf.subSequence(start, end); // str } }