java.io
Class PushbackReader

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.io.Reader sample code for java.io.Reader definition code for java.io.Reader 
      extended by java.io.FilterReader sample code for java.io.FilterReader definition code for java.io.FilterReader 
          extended by java.io.PushbackReader
All Implemented Interfaces:
Closeable sample code for java.io.Closeable definition code for java.io.Closeable , Readable sample code for java.lang.Readable definition code for java.lang.Readable

public class PushbackReader
extends FilterReader sample code for java.io.FilterReader definition code for java.io.FilterReader

A character-stream reader that allows characters to be pushed back into the stream.

Since:
JDK1.1

Field Summary
 
Fields inherited from class java.io.FilterReader sample code for java.io.FilterReader definition code for java.io.FilterReader
in sample code for java.io.FilterReader.in definition code for java.io.FilterReader.in
 
Fields inherited from class java.io.Reader sample code for java.io.Reader definition code for java.io.Reader
lock sample code for java.io.Reader.lock definition code for java.io.Reader.lock
 
Constructor Summary
PushbackReader sample code for java.io.PushbackReader.PushbackReader(java.io.Reader) definition code for java.io.PushbackReader.PushbackReader(java.io.Reader) (Reader sample code for java.io.Reader definition code for java.io.Reader  in)
          Create a new pushback reader with a one-character pushback buffer.
PushbackReader sample code for java.io.PushbackReader.PushbackReader(java.io.Reader, int) definition code for java.io.PushbackReader.PushbackReader(java.io.Reader, int) (Reader sample code for java.io.Reader definition code for java.io.Reader  in, int size)
          Create a new pushback reader with a pushback buffer of the given size.
 
Method Summary
 void close sample code for java.io.PushbackReader.close() definition code for java.io.PushbackReader.close() ()
          Close the stream.
 void mark sample code for java.io.PushbackReader.mark(int) definition code for java.io.PushbackReader.mark(int) (int readAheadLimit)
          Mark the present position in the stream.
 boolean markSupported sample code for java.io.PushbackReader.markSupported() definition code for java.io.PushbackReader.markSupported() ()
          Tell whether this stream supports the mark() operation, which it does not.
 int read sample code for java.io.PushbackReader.read() definition code for java.io.PushbackReader.read() ()
          Read a single character.
 int read sample code for java.io.PushbackReader.read(char[], int, int) definition code for java.io.PushbackReader.read(char[], int, int) (char[] cbuf, int off, int len)
          Read characters into a portion of an array.
 boolean ready sample code for java.io.PushbackReader.ready() definition code for java.io.PushbackReader.ready() ()
          Tell whether this stream is ready to be read.
 void reset sample code for java.io.PushbackReader.reset() definition code for java.io.PushbackReader.reset() ()
          Reset the stream.
 long skip sample code for java.io.PushbackReader.skip(long) definition code for java.io.PushbackReader.skip(long) (long n)
          Skip characters.
 void unread sample code for java.io.PushbackReader.unread(char[]) definition code for java.io.PushbackReader.unread(char[]) (char[] cbuf)
          Push back an array of characters by copying it to the front of the pushback buffer.
 void unread sample code for java.io.PushbackReader.unread(char[], int, int) definition code for java.io.PushbackReader.unread(char[], int, int) (char[] cbuf, int off, int len)
          Push back a portion of an array of characters by copying it to the front of the pushback buffer.
 void unread sample code for java.io.PushbackReader.unread(int) definition code for java.io.PushbackReader.unread(int) (int c)
          Push back a single character.
 
Methods inherited from class java.io.Reader sample code for java.io.Reader definition code for java.io.Reader
read sample code for java.io.Reader.read(char[]) definition code for java.io.Reader.read(char[]) , read sample code for java.io.Reader.read(java.nio.CharBuffer) definition code for java.io.Reader.read(java.nio.CharBuffer)
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

PushbackReader sample code for java.io.PushbackReader(java.io.Reader, int) definition code for java.io.PushbackReader(java.io.Reader, int)

public PushbackReader(Reader sample code for java.io.Reader definition code for java.io.Reader  in,
                      int size)
Create a new pushback reader with a pushback buffer of the given size.

Parameters:
in - The reader from which characters will be read
size - The size of the pushback buffer
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if size is <= 0

PushbackReader sample code for java.io.PushbackReader(java.io.Reader) definition code for java.io.PushbackReader(java.io.Reader)

public PushbackReader(Reader sample code for java.io.Reader definition code for java.io.Reader  in)
Create a new pushback reader with a one-character pushback buffer.

Parameters:
in - The reader from which characters will be read
Method Detail

read sample code for java.io.PushbackReader.read() definition code for java.io.PushbackReader.read()

public int read()
         throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Read a single character.

Overrides:
read sample code for java.io.FilterReader.read() definition code for java.io.FilterReader.read() in class FilterReader sample code for java.io.FilterReader definition code for java.io.FilterReader
Returns:
The character read, or -1 if the end of the stream has been reached
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - If an I/O error occurs

read sample code for java.io.PushbackReader.read(char[], int, int) definition code for java.io.PushbackReader.read(char[], int, int)

public int read(char[] cbuf,
                int off,
                int len)
         throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Read characters into a portion of an array.

Overrides:
read sample code for java.io.FilterReader.read(char[], int, int) definition code for java.io.FilterReader.read(char[], int, int) in class FilterReader sample code for java.io.FilterReader definition code for java.io.FilterReader
Parameters:
cbuf - Destination buffer
off - Offset at which to start writing characters
len - Maximum number of characters to read
Returns:
The number of characters read, or -1 if the end of the stream has been reached
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - If an I/O error occurs

unread sample code for java.io.PushbackReader.unread(int) definition code for java.io.PushbackReader.unread(int)

public void unread(int c)
            throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Push back a single character.

Parameters:
c - The character to push back
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - If the pushback buffer is full, or if some other I/O error occurs

unread sample code for java.io.PushbackReader.unread(char[], int, int) definition code for java.io.PushbackReader.unread(char[], int, int)

public void unread(char[] cbuf,
                   int off,
                   int len)
            throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Push back a portion of an array of characters by copying it to the front of the pushback buffer. After this method returns, the next character to be read will have the value cbuf[off], the character after that will have the value cbuf[off+1], and so forth.

Parameters:
cbuf - Character array
off - Offset of first character to push back
len - Number of characters to push back
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - If there is insufficient room in the pushback buffer, or if some other I/O error occurs

unread sample code for java.io.PushbackReader.unread(char[]) definition code for java.io.PushbackReader.unread(char[])

public void unread(char[] cbuf)
            throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Push back an array of characters by copying it to the front of the pushback buffer. After this method returns, the next character to be read will have the value cbuf[0], the character after that will have the value cbuf[1], and so forth.

Parameters:
cbuf - Character array to push back
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - If there is insufficient room in the pushback buffer, or if some other I/O error occurs

ready sample code for java.io.PushbackReader.ready() definition code for java.io.PushbackReader.ready()

public boolean ready()
              throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Tell whether this stream is ready to be read.

Overrides:
ready sample code for java.io.FilterReader.ready() definition code for java.io.FilterReader.ready() in class FilterReader sample code for java.io.FilterReader definition code for java.io.FilterReader
Returns:
True if the next read() is guaranteed not to block for input, false otherwise. Note that returning false does not guarantee that the next read will block.
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - If an I/O error occurs

mark sample code for java.io.PushbackReader.mark(int) definition code for java.io.PushbackReader.mark(int)

public void mark(int readAheadLimit)
          throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Mark the present position in the stream. The mark for class PushbackReader always throws an exception.

Overrides:
mark sample code for java.io.FilterReader.mark(int) definition code for java.io.FilterReader.mark(int) in class FilterReader sample code for java.io.FilterReader definition code for java.io.FilterReader
Parameters:
readAheadLimit - Limit on the number of characters that may be read while still preserving the mark. After reading this many characters, attempting to reset the stream may fail.
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - Always, since mark is not supported

reset sample code for java.io.PushbackReader.reset() definition code for java.io.PushbackReader.reset()

public void reset()
           throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Reset the stream. The reset method of PushbackReader always throws an exception.

Overrides:
reset sample code for java.io.FilterReader.reset() definition code for java.io.FilterReader.reset() in class FilterReader sample code for java.io.FilterReader definition code for java.io.FilterReader
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - Always, since reset is not supported

markSupported sample code for java.io.PushbackReader.markSupported() definition code for java.io.PushbackReader.markSupported()

public boolean markSupported()
Tell whether this stream supports the mark() operation, which it does not.

Overrides:
markSupported sample code for java.io.FilterReader.markSupported() definition code for java.io.FilterReader.markSupported() in class FilterReader sample code for java.io.FilterReader definition code for java.io.FilterReader
Returns:
true if and only if this stream supports the mark operation.

close sample code for java.io.PushbackReader.close() definition code for java.io.PushbackReader.close()

public void close()
           throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Close the stream.

Specified by:
close sample code for java.io.Closeable.close() definition code for java.io.Closeable.close() in interface Closeable sample code for java.io.Closeable definition code for java.io.Closeable
Overrides:
close sample code for java.io.FilterReader.close() definition code for java.io.FilterReader.close() in class FilterReader sample code for java.io.FilterReader definition code for java.io.FilterReader
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - If an I/O error occurs

skip sample code for java.io.PushbackReader.skip(long) definition code for java.io.PushbackReader.skip(long)

public long skip(long n)
          throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Skip characters. This method will block until some characters are available, an I/O error occurs, or the end of the stream is reached.

Overrides:
skip sample code for java.io.FilterReader.skip(long) definition code for java.io.FilterReader.skip(long) in class FilterReader sample code for java.io.FilterReader definition code for java.io.FilterReader
Parameters:
n - The number of characters to skip
Returns:
The number of characters actually skipped
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - If n is negative.
IOException sample code for java.io.IOException definition code for java.io.IOException - If an I/O error occurs