Java tutorial
import java.io.FilterWriter; import java.io.StringWriter; import java.io.Writer; public class Main { public static void main(String[] args) throws Exception { char[] cbuf = { 'A', 'B', 'C', 'D', 'E', 'F' }; Writer w = new StringWriter(6); FilterWriter fw = new FilterWriter(w) { }; fw.write(cbuf, 2, 4); String s = w.toString(); System.out.print(s); } }