A stream is a sequence of data of undetermined length, like a flowing stream of water with no end. In Java, input/output is handled by classes in the java.io package that differentiate data types - bytes use streams while text uses readers and writers. The main stream classes are InputStream and OutputStream which are abstract base classes for subclasses with specialized abilities like BufferedInputStream, FileInputStream, and ObjectInputStream.
Download as DOC, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
24 views
Java
A stream is a sequence of data of undetermined length, like a flowing stream of water with no end. In Java, input/output is handled by classes in the java.io package that differentiate data types - bytes use streams while text uses readers and writers. The main stream classes are InputStream and OutputStream which are abstract base classes for subclasses with specialized abilities like BufferedInputStream, FileInputStream, and ObjectInputStream.
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2
What is a Stream?
A stream is a sequence of data of undetermined length. It's called a stream because it's like a stream of water that continues to flow. There's no definite end to it.
Input and Output in Java
The java.io package contains classes that perform input and output. In Java, I/O classes are differentiated according to the type of data being read or written. Byte oriented and numeric data is written with output streams and read with input streams. Character data, that is text, is written with writers and read with readers. Whether you use streams or readers and writers depends on the type of data you're dealing with. All text data, especially non-ASCII text, should be passed through a reader or writer. The two main stream classes are java.io.InputStream and java.io.OutputStream. The two main reader and writer classes are java.io.Reader andjava.io.Writer These are abstract base classes for many different subclasses with more specialized abilities.
The Stream Classes
Most stream classes are part of the java.io package. (There are also a few more in the sun.io and sun.net packages, but those are deliberately hidden from you. There are also a couple in java.util.zip.) The two main classes are java.io.InputStream and java.io.OutputStream. These are abstract base classes for many different subclasses with more specialized abilities, including: BufferedInputStream BufferedOutputStream ByteArrayInputStream ByteArrayOutputStream DataInputStream DataOutputStream FileInputStream FileOutputStream FilterInputStream FilterOutputStream LineNumberInputStream ObjectInputStream