Java I/O streams; what are the differences?

Lawrence picture Lawrence · Jul 21, 2009 · Viewed 17.4k times · Source

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?

Answer

Michael Myers picture Michael Myers · Jul 21, 2009

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.