Bufferedreader Class Example

Source: Internet
Author: User

/*

Bufferedreader improves performance by buffering input. It has two constructor functions: bufferedreader (Reader inputstream) bufferedreader (Reader inputstream, int bufsize). The first method is to create a buffer stream with the default buffer length. Second, the buffer length is input by bufsize. Similar to throttling, buffering an input primary stream also provides the basis for supporting reverse movement in the available buffer. To support this, bufferedreader implements the mark () and reset () methods, and bufferedreader. marksupported () returns true ..

*/

// Use buffered input.
Import java. Io .*;
Class bufferedreaderdemo {
Public static void main (string [] ARGs) throws ioexception {
String S = "This Is A & copy; copyright symbol but this is & copy not./N ";
Char Buf [] = new char [S. Length ()];
S. getchars (0, S. Length (), Buf, 0 );
Chararrayreader in = new chararrayreader (BUF );
Bufferedreader F = new bufferedreader (in );
Int C;
Boolean marked = false;
While (C = f. Read ())! =-1 ){
Switch (c ){
Case '&':
If (! Marked ){
F. Mark (32 );
Marked = true;
} Else {
Marked = false;
}
Break;
Case ';':
If (marked ){
Marked = false;
System. Out. Print ("(c )");
} Else
System. Out. Print (char) C );
Break;

Case '':
If (marked ){
Marked = false;
F. Reset ();
System. Out. Print ("&");
} Else
System. Out. Print (char) C );
Break;

default:
If (! Marked)
system. out. print (char) C);
break;
}< BR >}

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.