Java Reference
In-Depth Information
LineNumberReader is a buffered reader that tracks the line numbers
of the input (characters only) ( Section 20.5.9 ).
SequenceInputStream converts a sequence of InputStream objects in-
to a single InputStream so that a list of concatenated input streams
can be treated as a single input stream (bytes only) ( Section
20.5.10 ).
There are also streams that are useful for building parsers:
Pushback streams add a pushback buffer you can use to put back
data when you have read too far ( Section 20.5.11 ).
The StreamTokenizer class breaks a Reader into a stream of tokens-
recognizable "words" that are often needed when parsing user in-
put (characters only) ( Section 20.5.12 ).
These classes can be extended to create new kinds of stream classes for
specific applications.
Each of these stream types is described in the following sections.
Before looking at these streams in detail, however, you need to learn
something about the synchronization behavior of the different streams.
20.5.1. Synchronization and Concurrency
Both the byte streams and the characters streams define synchroniza-
tion policies though they do this in different ways. The concurrent beha-
vior of the stream classes is not fully specified but can be broadly de-
scribed as follows.
Each byte stream class synchronizes on the current stream object when
performing operations that must be free from interference. This allows
multiple threads to use the same streams yet still get well-defined be-
havior when invoking individual stream methods. For example, if two
threads each try to read data from a stream in chunks of n bytes, then
the data returned by each read operation will contain up to n bytes
 
Search WWH ::




Custom Search