Writer.write(char[] cbuf, int off, int len) has the following syntax.
public abstract void write(char[] cbuf, int off, int len) throws IOException
In the following code shows how to use Writer.write(char[] cbuf, int off, int len) method.
//from www .j a v a 2 s .c o m import java.io.*; public class Main { public static void main(String[] args) { char[] c = {'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o', 'm'}; Writer writer = new PrintWriter(System.out); try { // write a portion of a char array writer.write(c, 0, 5); // flush the writer writer.flush(); // write another portion of a char array writer.write(c, 5, 5); // flush the stream again writer.close(); } catch (IOException ex) { ex.printStackTrace(); } } }
The code above generates the following result.