Closeable
, AutoCloseable
, Readable
This class implements a character buffer that can be used as a character-input stream.
Fields
protected char[]
protected int
The index of the end of this buffer.
protected int
The position of mark in buffer.
protected int
The current buffer position.
Constructors
Creates a CharArrayReader from the specified array of chars.
Creates a CharArrayReader from the specified array of chars.
void
Closes the stream and releases any system resources associated with it.
void
Marks the present position in the stream.
boolean
Tells whether this stream supports the mark() operation, which it does.
int
Reads a single character.
int
read(char[] cbuf, int off, int len)
Reads characters into a portion of an array.
boolean
Tells whether this stream is ready to be read.
void
Resets the stream to the most recent mark, or to the beginning if it has never been marked.
long
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
protected char[] buf
The character buffer.
protected int pos
The current buffer position.
protected int markedPos
The position of mark in buffer.
protected int count
The index of the end of this buffer. There is not valid data at or beyond this index.
public CharArrayReader(char[] buf)
Creates a CharArrayReader from the specified array of chars.
buf
- Input buffer (not copied)
public CharArrayReader(char[] buf, int offset, int length)
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.
buf
- Input buffer (not copied)
offset
- Offset of the first char to read
length
- Number of chars to read
IllegalArgumentException
- If offset
is negative or greater than buf.length
, or if length
is negative, or if the sum of these two values is negative.
Reads a single character.
read
in class Reader
0x00-0xffff
), or -1 if the end of the stream has been reached
IOException
- If an I/O error occurs
throws
IOExceptionIf len
is zero, then no characters are read and 0
is returned; otherwise, there is an attempt to read at least one character. If no character is available because the stream is at its end, the value -1
is returned; otherwise, at least one character is read and stored into cbuf
.
read
in class Reader
cbuf
- Destination buffer
off
- Offset at which to start storing characters
len
- Maximum number of characters to read
IndexOutOfBoundsException
- If off
is negative, or len
is negative, or len
is greater than cbuf.length - off
IOException
- If an I/O error occurs
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
.
skip
in class Reader
n
- The number of characters to skip
IOException
- If an I/O error occurs
Tells whether this stream is ready to be read. Character-array readers are always ready to be read.
ready
in class Reader
IOException
- If an I/O error occurs
public boolean markSupported()
Tells whether this stream supports the mark() operation, which it does.
markSupported
in class Reader
throws
IOExceptionMarks the present position in the stream. Subsequent calls to reset() will reposition the stream to this point.
mark
in class Reader
readAheadLimit
- Limit on the number of characters that may be read while still preserving the mark. Because the stream's input comes from a character array, there is no actual limit; hence this argument is ignored.
IOException
- If an I/O error occurs
Resets the stream to the most recent mark, or to the beginning if it has never been marked.
reset
in class Reader
IOException
- If an I/O error occurs
public void close()
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. This method will block while there is another thread blocking on the reader.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4