print() formats the output, while write() just prints the characters it is given. print() handles many argument types, converting them into printable strings of characters with String.valueOf(), while write() just handles single characters, arrays of characters, and strings.

To illustrate the difference, write(int) interprets the argument as a single character to be printed, while print(int) converts the integer into a character string. write(49) prints a "1", while print(49) prints "49".

source: http://www.coderanch.com/t/398792/java/java/write-print

Answer from Maantje on Stack Overflow
🌐
Baeldung
baeldung.com › home › java › java io › printwriter write() vs print() method in java
PrintWriter write() vs print() Method in Java | Baeldung
April 16, 2024 - As we saw, the PrintWriter class makes available several methods that help us print data to the output. The write() method prints the characters passed to it, while print() method translates the output.
Discussions

java - What is the exact difference between out.write() and out.print() - Stack Overflow
What is the exact difference between these two and when to use out.print and out.write ? ... The more complete answer is that out in servlets is a PrintWriter whose overloaded write() methods only accept a few basic types but do the work of outputting bytes to the underlying OutputStream. More on stackoverflow.com
🌐 stackoverflow.com
August 20, 2013
java - PrintWriter print vs println - Stack Overflow
nothing happens, meaning the server just keep waiting for a message that never arrive. When I change the out.print to out.println it works. ... Data buffering/flushing. ... It's more readable to use '\n' rather than (char) 10. ... By default, PrintWriter calls flush in println, whereas it doesn't ... More on stackoverflow.com
🌐 stackoverflow.com
July 5, 2017
Difference between `write` and `print`
The documentation entries for write and print seem very similar. There are a few minor differences (write allows file names as well as I/O streams and returns the number of bytes written, while print calls show if the argument doesn’t have a canonical text representation), but it seems like ... More on discourse.julialang.org
🌐 discourse.julialang.org
1
1
November 7, 2017
PrintWriter System.out differences...?
System.out is of PrintStream type and javadoc explains it verry well how it works. Basicaly System.out si configured to auto flush. https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/io/PrintStream.html More on reddit.com
🌐 r/learnjava
2
13
October 20, 2020
🌐
Coderanch
coderanch.com › t › 398792 › java › write-print
write() Vs print() (Beginning Java forum at Coderanch)
What is the difference between ... 20 years ago · Number of slices to send: Optional 'thank-you' note: Send · print() formats the output, while write() just prints the characters it is given....
🌐
Coderanch
coderanch.com › t › 277457 › java › difference-PrintWriter-println-PrintWriter-write
difference between PrintWriter.println and PrintWriter.write (I/O and Streams forum at Coderanch)
July 14, 2005 - The only evident difference is that println() prints a line separator ('\n') at the end of the output. That been said, behind the scenes, all print methods actually invoke the corresponding write methods.
🌐
Coderanch
coderanch.com › t › 174675 › certification › print-write-PrintWriter
print() Vs write() in PrintWriter (OCPJWCD forum at Coderanch)
The print methods seem to be wrappers around the write methods. print public void print(String s) Print a string. If the argument is null then the string "null" is printed. Otherwise, the string's characters are converted into bytes according to the platform's default character encoding, and these bytes are written in exactly the manner of the write(int) method.
🌐
Quora
quora.com › What-is-the-difference-between-a-print-stream-and-print-writer-in-Java
What is the difference between a print stream and print writer in Java? - Quora
Answer: PrintStream prints to an OutputStream, and PrintWriter prints to a Writer. Both are streams, but the difference is that OutputStream is a stream of bytes while a Writer is a stream of characters.
Find elsewhere
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › io › PrintWriter.html
PrintWriter (Java Platform SE 7 )
Unlike the PrintStream class, if ... println, printf, or format methods is invoked, rather than whenever a newline character happens to be output. These methods use the platform's own notion of line separator rather than the newline character. Methods in this class never throw I/O exceptions, although some of its constructors may. The client may inquire as to whether any errors have occurred by invoking checkError(). ... The underlying character-output stream of this PrintWriter...
🌐
Blogger
pragyarawal.blogspot.com › 2010 › 08 › printwriter-print-vs-write.html
All About Java and Interview Questions: PrintWriter : print() vs write()
August 2, 2010 - Then I realized that print() is ... of using only int /char array or string.So print() is just encapsulating the implementation of write() method by providing number of overlaoded method by which u can call the write()....
🌐
Programiz
programiz.com › java-programming › printwriter
Java PrintWriter (With Examples)
In this tutorial, we will learn about Java PrintWriter and its print() and printf() methods with the help of examples to print output data.
🌐
Coderanch
coderanch.com › t › 274674 › java › Difference-print-write
Difference between print and write (I/O and Streams forum at Coderanch)
The print and write methods are defined as given below print(boolean b) Print a boolean value. print(char c) Print a character. print(char[] s) Print an array of characters. print(double d) Print a double-precision floating-point number. print(float f) Print a floating-point number. print(int i) Print an integer. print(long l) Print a long integer. print(Object obj) Print an object. print(String s) Print a string. write(char[] buf)Write an array of characters. write(char[] buf, int off, int len)Write a portion of an array of characters. write(int c)Write a single character. write(String s)Writ
🌐
Tutorialspoint
tutorialspoint.com › home › java/io › java printwriter - print string
Java.io.PrintWriter.print( String s) Method
February 13, 2026 - The java.io.PrintWriter.print() method prints a string. If the argument is null then the string "null" is printed. Otherwise, the string's characters are converted into bytes according to the platform's default character encoding, and these ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › printwriter-writestring-method-in-java-with-examples
PrintWriter write(String) method in Java with Examples - GeeksforGeeks
July 11, 2025 - The write(String) method of PrintWriter Class in Java is used to write the specified String on the stream. This String value is taken as a parameter.
🌐
CodeGym
codegym.cc › java blog › java io & nio › java printwriter class
Java PrintWriter Class
January 9, 2025 - The most common practice to print data on the console is by using the System.out.print method. However, it is easier to customize the format as per the specified Locale (regional standards) while publishing global applications using the PrintWriter object.
🌐
DZone
dzone.com › coding › java › java printwriter with example
Java PrintWriter With Example
February 19, 2020 - The PrintWriter class implements all the methods of the PrintStream class. However, this class does not have any methods that are used for writing raw bytes. Note: the PrintWriter class is also used for write a file in Java.
🌐
Blogger
javaknow.blogspot.com › 2013 › 04 › print-vs-println-vs-write-method-of.html
Java interview question: print vs println vs write method of printwriter
April 26, 2013 - Println-> if println have any field which have null value then it print null. And break line after every call. print-->if println have ...
🌐
Reddit
reddit.com › r/learnjava › printwriter system.out differences...?
r/learnjava on Reddit: PrintWriter System.out differences...?
October 20, 2020 -

So I made some code to test a theory, and it disproved my theory. Here it is:

import java.io.PrintWriter;

public class Main {
    public static void main(String[] args) {
        PrintWriter writer = new PrintWriter(System.out);

        System.out.println("HI");
        writer.println("HI");
        writer.flush();
    }
}

Now here's the context for my question. I was taught that System.out is a stream object, and that the console grabs from the System.out stream and puts those contents on its stream. I was then taught that PrintWriter is an class that functions essentially identically to System.out, except that you can direct your destination stream. So I hypothesized, "If you made a PrintWriter object and sent the System.out stream in as its destination, would that be identical to just using System.out?

As it turns out, no, but I still don't fully understand why. What I do understand is that if I use the flush() method, it does essentially work the same. So my question is this:

When you use System.out.println() , does the method println() also tell the console to grab from the buffer so its not left in the System.out stream? And from the other perspective, when you use writer.println() (writer being the PrintWriter object in this context), does the println() method NOT tell the destination stream to grab from the buffer (until the flush() method is used)?

Any information helps, feel free to tell me that my interpretation is wrong or that my hypothesis is wrong. Or you can tell me anything really, tell me how your day is going. Any information helps, the more I know the better a programmer I can become :)

🌐
CodingTechRoom
codingtechroom.com › question › -printwriter-print-vs-println
Understanding the Difference Between Print and Println Methods in PrintWriter - CodingTechRoom
Copied · import java.io.PrintWriter; ... } catch (Exception e) { e.printStackTrace(); } } } The print() method outputs text without appending a newline character, keeping the cursor at the end of the current line....