public class CharSequenceReader extends Reader implements Serializable
Reader
implementation that can read from String, StringBuffer,
StringBuilder or CharBuffer.
Constructor and Description |
---|
CharSequenceReader(CharSequence charSequence)
Constructs a new instance with the specified character sequence.
|
CharSequenceReader(CharSequence charSequence,
int start)
Constructs a new instance with a portion of the specified character sequence.
|
CharSequenceReader(CharSequence charSequence,
int start,
int end)
Constructs a new instance with a portion of the specified character sequence.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close resets the file back to the start and removes any marked position.
|
void |
mark(int readAheadLimit)
Mark the current position.
|
boolean |
markSupported()
Mark is supported (returns true).
|
int |
read()
Read a single character.
|
int |
read(char[] array,
int offset,
int length)
Read the specified number of characters into the array.
|
boolean |
ready()
Tells whether this stream is ready to be read.
|
void |
reset()
Reset the reader to the last marked position (or the beginning if
mark has not been called).
|
long |
skip(long n)
Skip the specified number of characters.
|
String |
toString()
Return a String representation of the underlying
character sequence.
|
public CharSequenceReader(CharSequence charSequence)
charSequence
- The character sequence, may be null
public CharSequenceReader(CharSequence charSequence, int start)
The start index is not strictly enforced to be within the bounds of the
character sequence. This allows the character sequence to grow or shrink
in size without risking any IndexOutOfBoundsException
to be thrown.
Instead, if the character sequence grows smaller than the start index, this
instance will act as if all characters have been read.
charSequence
- The character sequence, may be null
start
- The start index in the character sequence, inclusiveIllegalArgumentException
- if the start index is negativepublic CharSequenceReader(CharSequence charSequence, int start, int end)
The start and end indexes are not strictly enforced to be within the bounds
of the character sequence. This allows the character sequence to grow or shrink
in size without risking any IndexOutOfBoundsException
to be thrown.
Instead, if the character sequence grows smaller than the start index, this
instance will act as if all characters have been read; if the character sequence
grows smaller than the end, this instance will use the actual character sequence
length.
charSequence
- The character sequence, may be null
start
- The start index in the character sequence, inclusiveend
- The end index in the character sequence, exclusiveIllegalArgumentException
- if the start index is negative, or if the end index is smaller than the start indexpublic void close()
public boolean ready()
public void mark(int readAheadLimit)
public boolean markSupported()
markSupported
in class Reader
true
public int read()
public int read(char[] array, int offset, int length)
public void reset()
public long skip(long n)
Jas4pp 1.5 © Java Analysis Studio for Particle Physics