Java IO Tutorial - Java PrintWriter.write(char[] buf)








Syntax

PrintWriter.write(char[] buf) has the following syntax.

public void write(char[] buf)

Example

In the following code shows how to use PrintWriter.write(char[] buf) method.

//from   ww  w. j  a v  a2s . c  om
import java.io.*;

public class Main {

   public static void main(String[] args) {
      char c = 'a';

      
      PrintWriter pw = new PrintWriter(System.out);

      // write char
      pw.write(c);
      pw.write('b');

      // flush the writer
      pw.flush();

   }
}

The code above generates the following result.