java.io.PushbackReader Maven / Gradle / Ivy
The newest version!
/*
This is not an official specification document, and usage is restricted.
NOTICE
(c) 2005-2007 Sun Microsystems, Inc. All Rights Reserved.
Neither this file nor any files generated from it describe a complete
specification, and they may only be used as described below. For
example, no permission is given for you to incorporate this file, in
whole or in part, in an implementation of a Java specification.
Sun Microsystems Inc. owns the copyright in this file and it is provided
to you for informative, as opposed to normative, use. The file and any
files generated from it may be used to generate other informative
documentation, such as a unified set of documents of API signatures for
a platform that includes technologies expressed as Java APIs. The file
may also be used to produce "compilation stubs," which allow
applications to be compiled and validated for such platforms.
Any work generated from this file, such as unified javadocs or compiled
stub files, must be accompanied by this notice in its entirety.
This work corresponds to the API signatures of JSR 219: Foundation
Profile 1.1. In the event of a discrepency between this work and the
JSR 219 specification, which is available at
http://www.jcp.org/en/jsr/detail?id=219, the latter takes precedence.
*/
package java.io;
/**
* A character-stream reader that allows characters to be pushed back into the
* stream.
*
* @version 1.14, 00/02/02
* @author Mark Reinhold
* @since JDK1.1
*/
public class PushbackReader extends FilterReader
{
/**
* Create a new pushback reader with a pushback buffer of the given size.
*
* @param in The reader from which characters will be read
* @param size The size of the pushback buffer
* @exception IllegalArgumentException if size is <= 0
*/
public PushbackReader(Reader in, int size) {
super(in);
}
/**
* Create a new pushback reader with a one-character pushback buffer.
*
* @param in The reader from which characters will be read
*/
public PushbackReader(Reader in) {
this(in, 1);
}
/**
* Read a single character.
*
* @return The character read, or -1 if the end of the stream has been
* reached
*
* @exception IOException If an I/O error occurs
*/
public int read() throws IOException {
return 0;
}
/**
* Read characters into a portion of an array.
*
* @param cbuf Destination buffer
* @param off Offset at which to start writing characters
* @param len Maximum number of characters to read
*
* @return The number of characters read, or -1 if the end of the
* stream has been reached
*
* @exception IOException If an I/O error occurs
*/
public int read(char[] cbuf, int off, int len) throws IOException {
return 0;
}
/**
* Push back a single character.
*
* @param c The character to push back
*
* @exception IOException If the pushback buffer is full,
* or if some other I/O error occurs
*/
public void unread(int c) throws 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.
*
* @param cbuf Character array
* @param off Offset of first character to push back
* @param len Number of characters to push back
*
* @exception IOException If there is insufficient room in the pushback
* buffer, or if some other I/O error occurs
*/
public void unread(char[] cbuf, int off, int len) throws 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.
*
* @param cbuf Character array to push back
*
* @exception IOException If there is insufficient room in the pushback
* buffer, or if some other I/O error occurs
*/
public void unread(char[] cbuf) throws IOException { }
/**
* Tell whether this stream is ready to be read.
*
* @exception IOException If an I/O error occurs
*/
public boolean ready() throws IOException {
return false;
}
/**
* Mark the present position in the stream. The mark
* for class PushbackReader
always throws an exception.
*
* @exception IOException Always, since mark is not supported
*/
public void mark(int readAheadLimit) throws IOException { }
/**
* Reset the stream. The reset
method of
* PushbackReader
always throws an exception.
*
* @exception IOException Always, since reset is not supported
*/
public void reset() throws IOException { }
/**
* Tell whether this stream supports the mark() operation, which it does
* not.
*/
public boolean markSupported() {
return false;
}
/**
* Close the stream.
*
* @exception IOException If an I/O error occurs
*/
public void close() throws 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.
*
* @param n The number of characters to skip
*
* @return The number of characters actually skipped
*
* @exception IllegalArgumentException If n
is negative.
* @exception IOException If an I/O error occurs
*/
public long skip(long n) throws IOException {
return -1;
}
}