Chararrayreader Class Example

Source: Internet
Author: User

/*

Chararrayreader is an implementation of using a character array as the source input stream. This class has two constructors, each of which requires an array of characters to provide the data source:
Chararrayreader (char array [])
Chararrayreader (char array [], int start, int numchars)
Here, array is the input source. The second constructor creates a reader from the subset of your character array, which starts with the index specified by start and has a length of numchars.

*/

// Demonstrate chararrayreader.
Import java. Io .*;
Class chararrayreaderdemo {
Public static void main (string [] ARGs) throws ioexception {
String strtmp = "abcdefghijklmnopqrstuvwxyz ";
Int intlen = strtmp. Length ();
Char C [] = new char [intlen];
Strtmp. getchars (0, intlen, C, 0 );
Chararrayreader input1 = new chararrayreader (C );
Chararrayreader input2 = new chararrayreader (C, 0, 5 );
Int I;
System. Out. println ("input1 is :");
While (I = input1.read ())! =-1 ){
System. Out. Print (char) I );
}
System. Out. println ();
System. Out. println ("input2 is :");
While (I = input2.read ())! =-1 ){
System. Out. Print (char) I );
}
System. Out. println ();
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.