Explore Java IO's Pushbackinputstream class

Source: Internet
Author: User

One of the new applications for caching is the implementation of the push back (pushback). The push-back is used for the input stream to allow the bytes to be read and then returned (pushed back) into the stream. The Pushbackinputstream class implements this idea and provides a mechanism for "peeping" from the contents of the input stream without destroying them.

The Pushbackinputstream class has the following constructors:

Pushbackinputstream (InputStream inputstream) pushbackinputstream (InputStream inputstream,int numBytes)

The first form creates a stream object that allows one byte to be returned to the input stream, and the second form creates a stream object with a numbytes-length push-back cache, allowing multiple bytes to be pushed back into the input stream.

In addition to the familiar approach from InputStream, the Pushbackinputstream class also provides the unread () method, as follows:

void unread (int b) void unread (byte[] buffer) void unread (byte[] buffer,int offset,int numbytes)

The first form pushes back the low byte of B, which causes subsequent read () calls to return to the next byte. The second form pushes back the bytes in buffer. The third form pushes back the NumBytes bytes in buffer starting with offset. When the rollback cache is full, an IOException exception is thrown if an attempt is made to push back the bytes.


Explore Java IO's Pushbackinputstream class

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.