Java tutorial
import java.io.CharArrayWriter; public class Main { public static void main(String[] args) { String str = "from java2s.com!"; CharArrayWriter chw = new CharArrayWriter(); // portion to be written to writer chw.write(str, 4, 9); // print the buffer as string System.out.println(chw.toString()); } }