StringWriter 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 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: This method accepts a mandatory parameter ascii which is the ASCII value of the byte value to be written on the writer. Return Value: This method does not returns any value. Below programs illustrates the working of write(int) method: Program 1: Java // Java program to demonstrate // StringWriter write(int) method import java.io.*; class GFG { public static void main(String[] args) { try { // Create a StringWriter instance StringWriter writer = new StringWriter(); // Write the byte value '0' to this writer // using write() method // This will put the string in the writer // till it is printed on the console writer.write(48); System.out.println(writer.toString()); } catch (Exception e) { System.out.println(e); } } } Output: 0 Program 2: Java // Java program to demonstrate // StringWriter write(int) method import java.io.*; class GFG { public static void main(String[] args) { try { // Create a StringWriter instance StringWriter writer = new StringWriter(); // Write the byte value 'A' to this writer // using write() method // This will put the string in the writer // till it is printed on the console writer.write(65); System.out.println(writer.toString()); } catch (Exception e) { System.out.println(e); } } } Output: A Comment More infoAdvertise with us Next Article StringWriter write(char[], int, int) method in Java with Examples C code_r Follow Improve Article Tags : Java Java-Functions Java-IO package Java-StringWriter 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 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 StringWriter write(char[], int, int) method in Java with Examples The write(char[], int, int) method of StringWriter Class in Java is used to write a specified portion of the specified character array on the writer. This character array is taken as a parameter. The starting index and length of characters to be written are also taken as parameters. Syntax: public v 2 min read StringWriter write(char[], int, int) method in Java with Examples The write(char[], int, int) method of StringWriter Class in Java is used to write a specified portion of the specified character array on the writer. This character array is taken as a parameter. The starting index and length of characters to be written are also taken as parameters. Syntax: public v 2 min read StringWriter write(String, int, int) method in Java with Examples The write(String, int, int) method of StringWriter 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 strin 2 min read StringWriter write(String, int, int) method in Java with Examples The write(String, int, int) method of StringWriter 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 strin 2 min read Like