CharArrayReader Read Character Array Java

CharArrayReader Read Character Array Java


The CharArrayReader is equivalent to ByteArrayInputStream. For ByteArrayInputStream, the source is a byte array and for CharArrayReader the source is a character array. The CharArrayReader reads characters from a character array either completely or partially starting from a offset. This classes supports mark() and reset() methods.

Following is the class signature

public class CharArrayReader extends Reader

Reading a Character Array

Example on CharArrayReader Read Character Array Java

CharArrayReader Read Character Array Java
Output screenshot on CharArrayReader Read Character Array Java

CharArrayReader careader1 = new CharArrayReader(carray);
CharArrayReader careader2 = new CharArrayReader(carray, 7, 12);

The character array carray is passed to two CharArrayReader constructors. The first CharArrayReader object careader1 reads complete array and the second object careader2 reads 12 characters starting from 7th.

Pass your comments and suggestions to improve the quality of this tutorial "CharArrayReader Read Character Array Java".

Leave a Reply

Your email address will not be published. Required fields are marked *