public final class CharSequenceReader extends Reader
This class allows any CharSequence to be used as
a reader.
| Constructor and Description |
|---|
CharSequenceReader()
Creates a new character sequence reader for which the character
sequence input is not set.
|
CharSequenceReader(CharSequence input)
Creates a new character sequence reader for which the character
sequence input is set.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes and
resets this reader for reuse. |
CharSequence |
getInput()
Returns the character sequence to use for reading.
|
int |
read()
Reads a single character.
|
void |
read(Appendable dest)
Reads characters into the specified appendable.
|
int |
read(char[] cbuf,
int off,
int len)
Reads characters into a portion of an array.
|
boolean |
ready()
Indicates if this stream is ready to be read.
|
void |
reset() |
void |
setInput(CharSequence input)
Sets the character sequence to use for reading.
|
public CharSequenceReader()
setInput(java.lang.CharSequence)public CharSequenceReader(CharSequence input)
input - the character sequence to be read.public void setInput(CharSequence input)
input - the character sequence to be read.IllegalStateException - if this reader is being reused and
it has not been closed or reset.public CharSequence getInput()
public boolean ready()
throws IOException
ready in class Readertrue if this reader has remaining characters to
read; false otherwise.IOException - if an I/O error occurs.public void close()
resets this reader for reuse.public int read()
throws IOException
-1
is returned if the end of the character sequence input has been reached.read in class ReaderIOException - if an I/O error occurs (e.g. incomplete
character sequence being read).public int read(char[] cbuf,
int off,
int len)
throws IOException
read in class Readercbuf - the destination buffer.off - the offset at which to start storing characters.len - the maximum number of characters to readIOException - if an I/O error occurs.public void read(Appendable dest) throws IOException
dest - the destination buffer.IOException - if an I/O error occurs.Copyright © 2017. All rights reserved.