public abstract class Reader extends Object implements Readable, Closeable
BufferedReader
,
LineNumberReader
,
CharArrayReader
,
InputStreamReader
,
FileReader
,
FilterReader
,
PushbackReader
,
PipedReader
,
StringReader
,
Writer
Modifier and Type | Field and Description |
---|---|
protected Object |
lock
The object used to synchronize operations on this stream.
|
Modifier | Constructor and Description |
---|---|
protected |
Reader()
Creates a new character-stream reader whose critical sections will
synchronize on the reader itself.
|
protected |
Reader(Object lock)
Creates a new character-stream reader whose critical sections will
synchronize on the given object.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
close()
Closes the stream and releases any system resources associated with
it.
|
void |
mark(int readAheadLimit)
Marks the present position in the stream.
|
boolean |
markSupported()
Tells whether this stream supports the mark() operation.
|
int |
read()
Reads a single character.
|
int |
read(char[] cbuf)
Reads characters into an array.
|
abstract int |
read(char[] cbuf,
int off,
int len)
Reads characters into a portion of an array.
|
int |
read(CharBuffer target)
Attempts to read characters into the specified character buffer.
|
boolean |
ready()
Tells whether this stream is ready to be read.
|
void |
reset()
Resets the stream.
|
long |
skip(long n)
Skips characters.
|
protected Object lock
protected Reader()
protected Reader(Object lock)
lock
- The Object to synchronize on.public int read(CharBuffer target) throws IOException
read
in interface Readable
target
- the buffer to read characters intoIOException
- if an I/O error occursNullPointerException
- if target is nullReadOnlyBufferException
- 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 bufferIOException
- 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 readIOException
- If an I/O error occurspublic long skip(long n) throws IOException
n
- The number of characters to skipIllegalArgumentException
- 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
close
in interface Closeable
close
in interface AutoCloseable
IOException
- If an I/O error occurs Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2012, Oracle and/or its affiliates. All rights reserved.