CharArrayReader Java Help

CharArrayReader

CharArrayWriter is an implementation of an input stream that uses a character array as the source. This class has two constructors, each of which requires a character array to provide the .data source:

Here, array is the input source. The second constructor creates a Reader from a subset of your character array that begins with the character at the index specified by start long.

The input object is constructed using the entire lowercase alphabet, while input contains only the first five letters. Here is the output.

CharArrayWriter 

CharArrayWriter is an implementation of an output that uses on array as the destination. CharArrayWriter has two constructors, shown here:

The following' example demonstrates CharArrayWriter by reworking the sample program shown earlier for ByteArrayOutputStream.1t. produces the same output as the previous version.

BufferedReader

Bufferedreader improves performance by buffering input. It has two constructors.

As is the case with the byte-oriented stream, buffering an input character stream also provides the foundation required to support moving backward in the stream within the available buffer. To.support this, BufferedReadcr implements the mark( ) .and resett) methods, and BufferedReader.markSupported( ) returns true.

The following example reworks the BufferedinputStream example, shown earlier, so that it uses a BufferedReader character stream rather than a buffered byte stream. As before, it uses mark( ) and reset( ) methods to parse a stream for the HTML entity reference for the copyright symbol. Such a reference begins with an ampersand () and ends with a semicolon ():without any intervening whitespace. The sample input has two ampersands, to show the case where the reset( ) happens and where it does not.Output is the same as that shown earlier.

Posted on September 18, 2014 in Input/output: Exploring java.io

Share the Story

About the Author

Back to Top
Share This