Java Reference
In-Depth Information
Table 4.1 lists the low-level and high-level streams from the java.io package.
TABLE 4.1
The Low-Level and High-Level Streams in the java.io Package
High-level Streams
Low-level Streams
FileInputStream
BufferedReader
BufferedInputStream
FileReader
FileOutputStream
BufferedWriter
BufferedOutputStream
FileWriter
ByteArrayInputStream
CharArrayWriter
DataInputStream
ObjectInputStream
StringReader
StringWriter
PipedInputStream
OutputStreamWriter
InputStream
OutputStream
PipedOutputStream
InputStreamReader
PushbackInput
Stream
LineNumberReader
PushbackReader
PushbackReader
Determining Low-level vs. High-level Streams
If you ever need to determine whether a java.io stream is a high-level or low-level
stream, just look at the constructors of the class. If the constructors take in an
existing stream object, then it is a high-level stream; otherwise, it is a low-level stream.
For example, the DataInputStream class has only one constructor:
public DataInputStream(InputStream is)
You cannot instantiate a DataInputStream unless you already have an existing stream to
pass in to the constructor. Therefore, DataInputStream must be a high-level stream.
Compare DataInputStream to FileInputStream , which has three constructors:
public FileInputStream(File file)
public FileInputStream(FileDescriptor fdObj)
public FileInputStream(String name)
Each constructor takes in some variation of a fi le, which is the source of the data and not
another stream class. Therefore, FileInputStream is a low-level stream.
Search WWH ::




Custom Search