Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java I/O streams; what are the differences?

Tags:

java.io has many different I/O streams, (FileInputStream, FileOutputStream, FileReader, FileWriter, BufferedStreams... etc.) and I am confused in determining the differences between them. What are some examples where one stream type is preferred over another, and what are the real differences between them?

like image 995
Lawrence Avatar asked Jul 21 '09 15:07

Lawrence


People also ask

How many types of I O streams are there in Java?

There are 3 categories of classes in java.io are as follows: Input Streams. Output Streams. Error Streams.

What is the difference between input and output stream in Java?

InputStream Read data from the source once at a time. 2. OutputStream Write Data to the destination once at a time.


1 Answers

Streams: one byte at a time. Good for binary data.

Readers/Writers: one character at a time. Good for text data.

Anything "Buffered": many bytes/characters at a time. Good almost all the time.

like image 110
Michael Myers Avatar answered Sep 19 '22 10:09

Michael Myers