info.aduna.io
Class PushbackReader

java.lang.Object
  extended by java.io.Reader
      extended by info.aduna.io.PushbackReader
All Implemented Interfaces:
Closeable, Readable

public class PushbackReader
extends Reader

A character-stream reader that allows characters, strings and even the contents of streams and readers to be pushed back into the stream. This class resembles java.io.PushbackReader but its pushback buffer has 'infinite' room for more characters.


Field Summary
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
PushbackReader()
          Creates a new PushbackReader.
PushbackReader(Reader r)
          Creates a new PushbackReader.
 
Method Summary
 void close()
           
 void pushback(char[] chars)
          Push a character array back into the stream.
 void pushback(char[] chars, int off, int len)
          Push a part of a character array back into the stream.
 void pushback(Reader r)
          Push the contents of a stream back into the stream.
 void pushback(String s)
          Push a string back into the stream.
 int read()
           
 int read(char[] cbuf, int off, int len)
           
 
Methods inherited from class java.io.Reader
mark, markSupported, read, read, ready, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PushbackReader

public PushbackReader()
Creates a new PushbackReader.


PushbackReader

public PushbackReader(Reader r)
Creates a new PushbackReader.

Parameters:
r - The first reader to be pushed back
Method Detail

pushback

public void pushback(Reader r)
Push the contents of a stream back into the stream.

Parameters:
r - The reader to push back

pushback

public void pushback(String s)
Push a string back into the stream.

Parameters:
s - The String to push back

pushback

public void pushback(char[] chars)
Push a character array back into the stream.

Parameters:
chars - The characters to push back

pushback

public void pushback(char[] chars,
                     int off,
                     int len)
Push a part of a character array back into the stream.

Parameters:
chars - The character array
off - Offset of first character to push back
len - Number of characters to push back

read

public int read()
         throws IOException
Overrides:
read in class Reader
Throws:
IOException

read

public int read(char[] cbuf,
                int off,
                int len)
         throws IOException
Specified by:
read in class Reader
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Specified by:
close in class Reader
Throws:
IOException


Copyright © 2011 Aduna. All Rights Reserved.