PrintStream write(int) method in Java with Examples Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The write(int) method of PrintStream Class in Java is used to write the specified byte value on the stream. This byte value is specified using the ASCII value of the byte value passed as an integer value. This integer value is taken as a parameter. Syntax: public void write(int ascii) Parameters: This method accepts a mandatory parameter ascii which is the ASCII value of the byte value to be written on the stream. Return Value: This method do not returns any value. Below methods illustrates the working of write(int) method: Program 1: Java // Java program to demonstrate // PrintStream write(int) method import java.io.*; class GFG { public static void main(String[] args) { try { // Create a PrintStream instance PrintStream stream = new PrintStream(System.out); // Write the byte value '0' to this stream // using write() method // This will put the string in the stream // till it is printed on the console stream.write(48); stream.flush(); } catch (Exception e) { System.out.println(e); } } } Output: 0 Program 2: Java // Java program to demonstrate // PrintStream write(int) method import java.io.*; class GFG { public static void main(String[] args) { try { // Create a PrintStream instance PrintStream stream = new PrintStream(System.out); // Write the byte value 'A' to this stream // using write() method // This will put the string in the stream // till it is printed on the console stream.write(65); stream.flush(); } catch (Exception e) { System.out.println(e); } } } Output: A Comment More infoAdvertise with us Next Article PrintWriter write(int) method in Java with Examples K Kirti_Mangal Follow Improve Article Tags : Java Java-Functions Java-IO package Java-PrintStream Practice Tags : Java Similar Reads PrintWriter write(int) method in Java with Examples The write(int) method of PrintWriter Class in Java is used to write the specified character on the stream. This character is specified using the ASCII value of the character passed as an integer value. This integer value is taken as a parameter. Syntax: public void write(int ascii) Parameters: This 2 min read PrintStream write(byte[], int, int) method in Java with Examples The write(byte[], int, int) method of PrintStream Class in Java is used to write a specified portion of the specified byteacter array on the stream. This byteacter array is taken as a parameter. The starting index and length of byteacters to be written are also taken as parameters. Syntax: public vo 2 min read PrintStream print(int) method in Java with Examples The print(int) method of PrintStream Class in Java is used to print the specified int value on the stream. This int value is taken as a parameter. Syntax: public void print(int intValue) Parameters: This method accepts a mandatory parameter intValue which is the int value to be written on the stream 2 min read StringWriter write(int) method in Java with Examples The write(int) method of StringWriter Class in Java is used to write the specified byte value on the writer. This byte value is specified using the ASCII value of the byte value passed as an integer value. This integer value is taken as a parameter. Syntax: public void write(int ascii) Parameters: T 2 min read PrintStream println(int) method in Java with Examples The println(int) method of PrintStream Class in Java is used to print the specified int value on the stream and then break the line. This int value is taken as a parameter. Syntax: public void println(int intValue) Parameters: This method accepts a mandatory parameter intValue which is the int value 2 min read PrintWriter write(String, int, int) method in Java with Examples The write(String, int, int) method of PrintWriter Class in Java is used to write a specified portion of the specified String on the stream. This String is taken as a parameter. The starting index and length of String to be written are also taken as parameters. Syntax: public void write(String string 2 min read Like