|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object extended by java.io.Reader
Abstract class for reading character streams. The only methods that a subclass must implement are read(char[], int, int) and close(). Most subclasses, however, will override some of the methods defined here in order to provide higher efficiency, additional functionality, or both.
BufferedReader,
LineNumberReader,
CharArrayReader,
InputStreamReader,
FileReader,
FilterReader,
PushbackReader,
PipedReader,
StringReader,
Writer
| Field Summary | |
|---|---|
protected Object |
lock
The object used to synchronize operations on this stream. |
| Constructor Summary | |
|---|---|
protected |
Reader()
Create a new character-stream reader whose critical sections will synchronize on the reader itself. |
protected |
Reader(Object lock)
Create a new character-stream reader whose critical sections will synchronize on the given object. |
| Method Summary | |
|---|---|
abstract void |
close()
Close the stream. |
void |
mark(int readAheadLimit)
Mark the present position in the stream. |
boolean |
markSupported()
Tell whether this stream supports the mark() operation. |
int |
read()
Read a single character. |
int |
read(char[] cbuf)
Read characters into an array. |
abstract int |
read(char[] cbuf,
int off,
int len)
Read characters into a portion of an array. |
int |
read(CharBuffer target)
Attempts to read characters into the specified character buffer. |
boolean |
ready()
Tell whether this stream is ready to be read. |
void |
reset()
Reset the stream. |
long |
skip(long n)
Skip characters. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Object lock
| Constructor Detail |
|---|
protected Reader()
protected Reader(Object lock)
lock - The Object to synchronize on.| Method Detail |
|---|
public int read(CharBuffer target) throws IOException
target - the buffer to read characters into
IOException - if an I/O error occurs
NullPointerException - if target is null
ReadOnlyBufferException - if target is a read only bufferpublic int read() throws IOException
Subclasses that intend to support efficient single-character input should override this method.
IOException - If an I/O error occurspublic int read(char[] cbuf) throws IOException
cbuf - Destination buffer
IOException - If an I/O error occurspublic abstract int read(char[] cbuf, int off, int len) throws IOException
cbuf - Destination bufferoff - Offset at which to start storing characterslen - Maximum number of characters to read
IOException - If an I/O error occurspublic long skip(long n) throws IOException
n - The number of characters to skip
IllegalArgumentException - If n is negative.
IOException - If an I/O error occurspublic boolean ready() throws IOException
IOException - If an I/O error occurspublic boolean markSupported()
public void mark(int readAheadLimit) throws IOException
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.
IOException - If the stream does not support mark(),
or if some other I/O error occurspublic void reset() throws IOException
IOException - If the stream has not been marked,
or if the mark has been invalidated,
or if the stream does not support reset(),
or if some other I/O error occurspublic abstract void close() throws IOException
IOException - If an I/O error occurs
|
JavaTM 2 Platform Standard Ed. 5.0 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.