Streams (Overview)

A stream is a flow of characters to and from a program. The other end of the stream can be anything that can accept or generate a stream of characters, including a console window, a printer, a file on a disk drive, or even another program.

The two basic types of streams in Java are

check.png Character streams: Character streams read and write text characters that represent strings. You can connect a character stream to a text file to store text data on a hard drive. Typically, text files use special characters called delimiters — such as commas or Tabs — to separate elements of the file.

check.png Binary streams: Binary streams read and write individual bytes that represent primitive data types. You can connect a binary stream to a binary file to store binary data on a hard drive. The contents of binary files make perfect sense to the programs that read and write them, but if you try to open a binary file in a text editor, the file’s contents look like gibberish.

Many of the classes described in this part are designed to facilitate stream I/O. For character streams, these classes are

check.png Reader : An abstract class that the other reader classes extend.

FileReader : Provides basic methods ...

Get Java For Dummies Quick Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.