Writer write(String) method in Java with Examples Last Updated : 11 Mar, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report The write(String) method of Writer Class in Java is used to write the specified String on the stream. This String value is taken as a parameter. Syntax: public void write(String string) Parameters: This method accepts a mandatory parameter string which is the String to be written in the Stream. Return Value: This method do not returns any value. Below methods illustrates the working of write(String) method: Program 1: Java // Java program to demonstrate // Writer write(String) method import java.io.*; class GFG { public static void main(String[] args) { try { // Create a Writer instance Writer writer = new PrintWriter(System.out); // Write the String 'GeeksForGeeks' // to this writer using write() method // This will put the string in the stream // till it is printed on the console writer.write("GeeksForGeeks"); writer.flush(); } catch (Exception e) { System.out.println(e); } } } Output: GeeksForGeeks Program 2: Java // Java program to demonstrate // Writer write(String) method import java.io.*; class GFG { public static void main(String[] args) { try { // Create a Writer instance Writer writer = new PrintWriter(System.out); // Write the String 'GFG' // to this writer using write() method // This will put the string in the stream // till it is printed on the console writer.write("GFG"); writer.flush(); } catch (Exception e) { System.out.println(e); } } } Output: GFG Comment More infoAdvertise with us Next Article Writer write(String, int, int) method in Java with Examples C code_r Follow Improve Article Tags : Java Java-Functions Java-IO package Java-Writer Practice Tags : Java Similar Reads Writer write(String, int, int) method in Java with Examples The write(String, int, int) method of Writer 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, int 2 min read Writer write(int) method in Java with Examples The write(int) method of Writer 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 me 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 Writer write(char[]) method in Java with Examples The write(char[]) method of Writer Class in Java is used to write the specified character array on the stream. This character array is taken as a parameter. Syntax: public void write(char[] charArray) Parameters: This method accepts a mandatory parameter charArray which is the character array to be 2 min read StringWriter write(String) method in Java with Examples The write(String) method of StringWriter Class in Java is used to write the specified String on the stream. This String value is taken as a parameter. Syntax: public void write(String string) Parameters: This method accepts a mandatory parameter string which is the String to be written in the Stream 2 min read Year toString() method in Java with Examples The toString() method of Year class in Java is used to return the string representation of this Year object. Syntax: public String toString() Parameter: This method does not accepts any parameter. Return Value: It returns the string representation of this Year object. Below programs illustrate the t 1 min read Like