| |
|
| java.lang.Object java.io.Reader java.io.CharArrayReader
CharArrayReader | public class CharArrayReader extends Reader (Code) | | This class implements a character buffer that can be used as a
character-input stream.
author: Herb Jellinek version: 1.31, 05/05/07 since: JDK1.1 |
Field Summary | |
protected char | buf The character buffer. | protected int | count The index of the end of this buffer. | protected int | markedPos The position of mark in buffer. | protected int | pos The current buffer position. |
Constructor Summary | |
public | CharArrayReader(char buf) Creates a CharArrayReader from the specified array of chars. | public | CharArrayReader(char buf, int offset, int length) Creates a CharArrayReader from the specified array of chars.
The resulting reader will start reading at the given
offset. |
Method Summary | |
public void | close() Closes the stream and releases any system resources associated with
it. | public void | mark(int readAheadLimit) Marks the present position in the stream. | public boolean | markSupported() Tells whether this stream supports the mark() operation, which it does. | public int | read() Reads a single character. | public int | read(char b, int off, int len) Reads characters into a portion of an array. | public boolean | ready() Tells whether this stream is ready to be read. | public void | reset() Resets the stream to the most recent mark, or to the beginning if it has
never been marked. | public long | skip(long n) Skips characters. |
buf | protected char buf(Code) | | The character buffer.
|
count | protected int count(Code) | | The index of the end of this buffer. There is not valid
data at or beyond this index.
|
markedPos | protected int markedPos(Code) | | The position of mark in buffer.
|
pos | protected int pos(Code) | | The current buffer position.
|
CharArrayReader | public CharArrayReader(char buf)(Code) | | Creates a CharArrayReader from the specified array of chars.
Parameters: buf - Input buffer (not copied) |
CharArrayReader | public CharArrayReader(char buf, int offset, int length)(Code) | | Creates a CharArrayReader from the specified array of chars.
The resulting reader will start reading at the given
offset. The total number of char values that can be
read from this reader will be either length or
buf.length-offset, whichever is smaller.
throws: IllegalArgumentException - If offset is negative or greater thanbuf.length, or if length is negative, or ifthe sum of these two values is negative. Parameters: buf - Input buffer (not copied) Parameters: offset - Offset of the first char to read Parameters: length - Number of chars to read |
close | public void close()(Code) | | Closes the stream and releases any system resources associated with
it. Once the stream has been closed, further read(), ready(),
mark(), reset(), or skip() invocations will throw an IOException.
Closing a previously closed stream has no effect.
|
mark | public void mark(int readAheadLimit) throws IOException(Code) | | Marks the present position in the stream. Subsequent calls to reset()
will reposition the stream to this point.
Parameters: readAheadLimit - Limit on the number of characters that may beread while still preserving the mark. Becausethe stream's input comes from a character array,there is no actual limit; hence this argument isignored. exception: IOException - If an I/O error occurs |
markSupported | public boolean markSupported()(Code) | | Tells whether this stream supports the mark() operation, which it does.
|
read | public int read(char b, int off, int len) throws IOException(Code) | | Reads characters into a portion of an array.
Parameters: b - Destination buffer Parameters: off - Offset at which to start storing characters Parameters: len - Maximum number of characters to read The actual number of characters read, or -1 ifthe end of the stream has been reached exception: IOException - If an I/O error occurs |
ready | public boolean ready() throws IOException(Code) | | Tells whether this stream is ready to be read. Character-array readers
are always ready to be read.
exception: IOException - If an I/O error occurs |
reset | public void reset() throws IOException(Code) | | Resets the stream to the most recent mark, or to the beginning if it has
never been marked.
exception: IOException - If an I/O error occurs |
skip | public long skip(long n) throws IOException(Code) | | Skips characters. Returns the number of characters that were skipped.
The n parameter may be negative, even though the
skip method of the
Reader superclass throws
an exception in this case. If n is negative, then
this method does nothing and returns 0 .
Parameters: n - The number of characters to skip The number of characters actually skipped exception: IOException - If the stream is closed, or an I/O error occurs |
|
|
|