PushbackInputStream class methods in Java

java.io.PushbackInputStream

A PushbackInputStream adds functionality to another input stream, namely the ability to "push back" or "unread" bytes, by storing pushed-back bytes in an internal buffer.

This is useful in situations where it is convenient for a fragment of code to read an indefinite number of data bytes that are delimited by a particular byte value; after reading the terminating byte, the code fragment can "unread" it so that the next read operation on the input stream will reread the byte that was pushed back.

Implemented Interfaces

Closeable

AutoCloseable

Some methods of PushbackInputStream class

available()This method returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking the next invocation of a method for this input stream.

mark(int)This method marks the current position in this input stream.

markSupported()This method tests if this input stream supports the mark and reset methods, which it does not.

PushbackInputStream(InputStream)This method creates a PushbackInputStream with a 1-byte pushback buffer and saves its argument, the input stream, for later use.

PushbackInputStream(InputStream, int)This method creates a PushbackInputStream with a pushback buffer of the specified size, and saves its argument, the input stream, for later use.

read()This method reads the next byte of data from this input stream.

read(byte[], int, int)This method reads up to len bytes of data from this input stream into an array of bytes.

reset()This method repositions this stream to the position at the time the mark method was last called on this input stream.

skip(long)This method skips over and discards n bytes of data from this input stream.

unread(byte[])This method pushes back an array of bytes by copying it to the front of the pushback buffer.

unread(int)This method pushes back a byte by copying it to the front of the push-back buffer.

unread(byte[], int, int)This method pushes back a portion of an array of bytes by copying it to the front of the pushback buffer.

No comments:

Post a Comment