Types of OutputStream
This category includes the classes that decide where your output will go: an array of bytes (no String, however; presumably, you can create one using the array of bytes), a file, or a “pipe.”
In addition, the FilterOutputStream provides a base class for "decorator" classes that attach attributes or useful interfaces to output streams. This is discussed later.
Table 12-2. Types of OutputStream
Class
|
Function
|
Constructor Arguments
|
How to use it
|
ByteArray-OutputStream
|
Creates a buffer in memory. All the data that you send to the stream is placed in this buffer.
|
Optional initial size of the buffer.
|
To designate the destination of your data: Connect it to a FilterOutputStream object to provide a useful interface.
|
File-OutputStream
|
For sending information to a file.
|
A String representing the file name, or a File or FileDescriptor object.
|
To designate the destination of your data: Connect it to a FilterOutputStream object to provide a useful interface.
|
Piped-OutputStream
|
Any information you write to this automatically ends up as input for the associated PipedInput-Stream. Implements the “piping” concept.
|
PipedInputStream
|
To designate the destination of your data for multithreading: Connect it to a FilterOutputStream object to provide a useful interface.
|
Filter-OutputStream
|
Abstract class that is an interface for decorators that provide useful functionality to the other OutputStream classes. See Table 12-4.
|
See Table 12-4.
|
See Table 12-4.
|