PrintWriter.write(char[] buf, int off, int len) has the following syntax.
public void write(char[] buf, int off, int len)
In the following code shows how to use PrintWriter.write(char[] buf, int off, int len) method.
/* www .j a v a 2 s .c om*/ import java.io.*; public class Main { public static void main(String[] args) { char[] c = {'a', 'b', 'c', 'd', 'e', 'f'}; PrintWriter pw = new PrintWriter(System.out); // write char pw.write(c, 1, 3); pw.write(c, 3, 3); // flush the writer pw.flush(); } }
The code above generates the following result.