DthingApi
|
Public Member Functions | |
abstract void | close () throws IOException |
void | mark (int readLimit) throws IOException |
boolean | markSupported () |
int | read () throws IOException |
int | read (char[] buf) throws IOException |
abstract int | read (char[] buf, int offset, int count) throws IOException |
boolean | ready () throws IOException |
void | reset () throws IOException |
long | skip (long charCount) throws IOException |
Protected Member Functions | |
Reader () | |
Reader (Object lock) | |
Protected Attributes | |
Object | lock |
The base class for all readers. A reader is a means of reading data from a source in a character-wise manner. Some readers also support marking a position in the input and returning to this position later.
This abstract class does not provide a fully working implementation, so it needs to be subclassed, and at least the read(char[], int, int) and close() methods needs to be overridden. Overriding some of the non-abstract methods is also often advised, since it might result in higher efficiency.
Many specialized readers for purposes like reading from a file already exist in this package.
|
inlineprotected |
|
inlineprotected |
|
abstract |
Closes this reader. Implementations of this method should free any resources associated with the reader.
IOException | if an error occurs while closing this reader. |
|
inline |
Sets a mark position in this reader. The parameter
indicates how many characters can be read before the mark is invalidated. Calling
will reposition the reader back to the marked position if
has not been surpassed.
This default implementation simply throws an
; subclasses must provide their own implementation.
readLimit | the number of characters that can be read before the mark is invalidated. |
IllegalArgumentException | if readLimit < 0 |
IOException | if an error occurs while setting a mark in this reader. |
|
inline |
|
inline |
Reads a single character from this reader and returns it as an integer with the two higher-order bytes set to 0. Returns -1 if the end of the reader has been reached.
IOException | if this reader is closed or some other I/O error occurs. |
|
inline |
Reads characters from this reader and stores them in the character array
starting at offset 0. Returns the number of characters actually read or -1 if the end of the reader has been reached.
buf | character array to store the characters read. |
IOException | if this reader is closed or some other I/O error occurs. |
|
abstract |
Reads at most
characters from this reader and stores them at
in the character array
. Returns the number of characters actually read or -1 if the end of the reader has been reached.
buf | the character array to store the characters read. |
offset | the initial position in buffer |
count | the maximum number of characters to read. |
IOException | if this reader is closed or some other I/O error occurs. |
|
inline |
Indicates whether this reader is ready to be read without blocking. Returns
if this reader will not block when
is called,
if unknown or blocking will occur. This default implementation always returns
.
IOException | if this reader is closed or some other I/O error occurs. |
|
inline |
Resets this reader's position to the last
location. Invocations of
and
will occur from this new location. If this reader has not been marked, the behavior of
is implementation specific. This default implementation throws an
.
IOException | always thrown in this default implementation. |
|
inline |
Skips
characters in this reader. Subsequent calls of
methods will not return these characters unless
is used. This method may perform multiple reads to read
characters.
IllegalArgumentException | if charCount < 0 |
IOException | if this reader is closed or some other I/O error occurs. |
|
protected |
The object used to synchronize access to the reader.