Writer.write(char[] cbuf) has the following syntax.
public void write(char[] cbuf) throws IOException
In the following code shows how to use Writer.write(char[] cbuf) method.
/*from w ww .j a v a 2 s . c o m*/ import java.io.*; public class Main { public static void main(String[] args) { char[] c1 = {'h', 'e', 'l', 'l', 'o'}; char[] c2 = {'w', 'o', 'r', 'l', 'd'}; Writer writer = new PrintWriter(System.out); try { // write a char array writer.write(c1); // flush the writer writer.flush(); // write a new char array writer.write(c2); // flush the stream again writer.close(); } catch (IOException ex) { ex.printStackTrace(); } } }
The code above generates the following result.