[Java iO] _ rollback stream notes

Source: Internet
Author: User

[Java iO] _ rollback stream notes

Objectives of this chapter:
Master the working principle of the rollback stream
Use the pushbackinputstream class to perform the rollback operation.

Common Methods of pushbackinputstream class

Instance code:

Import Java. io. bytearrayinputstream; import Java. io. pushbackinputstream; public class pushinputstreamdemo {public static void main (string ARGs []) throws exception {// All exceptions throw string STR = "www.mldnjava.cn"; // defines the string pushbackinputstream push = NULL; // define the Back-to-Stream object bytearrayinputstream Bai = NULL; // define the memory input stream Bai = new bytearrayinputstream (Str. getbytes (); // instantiate the memory input stream push = new pushbackinputstream (Ba I); // read data from memory system. out. print ("the data after reading is:"); int temp = 0; while (temp = Push. read ())! =-1) {// read the content if (temp = '. ') {// judge whether the read is ". "Push. unread (temp); // put it back into the buffer. Temp = Push. read (); // read the system again. out. print ("(returned" + (char) temp + ")");} else {system. out. print (char) temp); // output content }}}};

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.