Java IO Tutorial - Java PrintStream.write(int b)








Syntax

PrintStream.write(int b) has the following syntax.

public void write(int b)

Example

In the following code shows how to use PrintStream.write(int b) method.

/*w  w  w  .  j  a v a  2  s . c  o m*/


import java.io.*;

public class Main {

   public static void main(String[] args) {
      byte c = 70;

      
      PrintStream ps = new PrintStream(System.out);

      // write byte c which is character F in ASCII
      ps.write(c);

      // flush the stream
      ps.flush();

   }
}

The code above generates the following result.