Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is System.out buffered or unbuffered?

Tags:

java

Is System.out buffered or unbuffered?

I read this is an object of InputStream and PrinterStream is the type of object referenced by System.out.

And they Both are Unbuffered so Why println() flushes the unbuffered...is it possible to flush unbuffered and I have read they are written immediately.

like image 952
Muhammad Yasir Avatar asked Jun 25 '14 06:06

Muhammad Yasir


2 Answers

System.out is the "standard" output. On most operating systems that terminal io is buffered, and paging is supported.

From the Javadoc,

The "standard" output stream. This stream is already open and ready to accept output data. Typically this stream corresponds to display output or another output destination specified by the host environment or user.

like image 200
Elliott Frisch Avatar answered Oct 06 '22 00:10

Elliott Frisch


From http://docs.oracle.com/javase/8/docs/api/java/io/PrintStream.html :

Optionally, a PrintStream can be created so as to flush automatically; this means that the flush method is automatically invoked after a byte array is written, one of the println methods is invoked, or a newline character or byte ('\n') is written.

like image 20
DavidPostill Avatar answered Oct 06 '22 01:10

DavidPostill