|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.io.Reader
Untamed: 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. |
private static int |
maxSkipBufferSize
Maximum skip-buffer size |
private char[] |
skipBuffer
Skip buffer, null until allocated |
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()
Enabled: Close the stream. |
String |
getText()
Added: Gets the rest of the input as a String, normalizing newlines into '\n's. |
Twine |
getTwine(String url)
Added: Gets the contents of the url as Twine (a text string that remembers where it came from), normalizing newlines into '\n's. |
void |
iterate(AssocFunc func)
Added: Enumerates lineNumber => String (text line) associations. |
void |
iterate(AssocFunc func,
String optURL)
Added: Enumerates lineNumber => String/Twine (text line) associations. |
void |
mark(int readAheadLimit)
Enabled: Mark the present position in the stream. |
boolean |
markSupported()
Enabled: Tell whether this stream supports the mark() operation. |
int |
read()
Enabled: Read a single character. |
int |
read(char[] cbuf)
Enabled: Read characters into an array. |
abstract int |
read(char[] cbuf,
int off,
int len)
Enabled: Read characters into a portion of an array. |
Character |
readChar()
Added: Returns the next character, or null at end of file. |
String |
readString(int size)
Added: Reads no more than 'size' characters from the file, and return them as a String. |
boolean |
ready()
Enabled: Tell whether this stream is ready to be read. |
void |
reset()
Enabled: Reset the stream. |
long |
skip(long n)
Enabled: 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
private static final int maxSkipBufferSize
private char[] skipBuffer
Constructor Detail |
protected Reader()
protected Reader(Object lock)
lock
- The Object to synchronize on.Method Detail |
public int read() throws IOException
Subclasses that intend to support efficient single-character input should override this method.
IOException
public int read(char[] cbuf) throws IOException
cbuf
- Destination buffer
IOException
public 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
public long skip(long n) throws IOException
n
- The number of characters to skip
IOException
public boolean ready() throws IOException
IOException
public 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
public void reset() throws IOException
IOException
public abstract void close() throws IOException
IOException
public Character readChar() throws IOException
IOException
public void iterate(AssocFunc func, String optURL) throws IOException
Each text line ends with a "\n".
IOException
public void iterate(AssocFunc func) throws IOException
Each text line ends with a "\n". optURL defaults to null.
IOException
public String getText() throws IOException
IOException
public Twine getTwine(String url) throws IOException
IOException
public String readString(int size) throws IOException
IOException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |