Java IO Tutorial - Java PrintWriter.write(int c)








Syntax

PrintWriter.write(int c) has the following syntax.

public void write(int c)

Example

In the following code shows how to use PrintWriter.write(int c) method.

/*from w w w  . jav a2 s . c o  m*/
import java.io.*;

public class Main {

   public static void main(String[] args) {
      int i = 70;

      
      PrintWriter pw = new PrintWriter(System.out);

      // write integer as ASCII characters
      pw.write(i);
      pw.write(76);

      // flush the writer
      pw.flush();

   }
}

The code above generates the following result.