Advanced Streams


Piped Streams

You use piped streams for a safe I/O-based data communication channel between different threads. Piped streams work in pairs: Data written to a piped output stream is read from a piped input stream to which it is attached. The piped stream implementations are PipedInputStream, PipedOutputStream, PipedReader, and PipedWriter. Refer to Lesson 13 for more information on multithreading.

SequenceInputStream

You can use a SequenceInputStream to allow a collection of input sources to act as a single input stream. The collection of sources is ordered; when one source is fully read, it is closed and the next stream in the collection is opened for reading.

Pushback Streams

The primary use of pushback streams (PushbackInputStream and PushbackReader) is for lexical analysis programs such as a tokenizer for a compiler. They allow data to be put back onto a stream as if it had not yet been read by the stream.

StreamTokenizer

The primary use of StreamTokenizer is also in parsing applications. It acts similarly to StringTokenizer. Instead of returning only strings from the underlying stream, however, a StreamTokenizer returns the type of the token in addition to the value. A token type may be a word, a number, an end-of-line marker, or an end-of-file marker.



Agile Java. Crafting Code with Test-Driven Development
Agile Javaв„ў: Crafting Code with Test-Driven Development
ISBN: 0131482394
EAN: 2147483647
Year: 2003
Pages: 391
Authors: Jeff Langr

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net