Class CharSequenceReader
- All Implemented Interfaces:
- Closeable,- Serializable,- AutoCloseable,- Readable
Reader implementation that can read from String, StringBuffer,
 StringBuilder or CharBuffer.
 
 Note: Supports mark(int) and reset().
 
Deprecating Serialization
Serialization is deprecated and will be removed in 3.0.
- Since:
- 1.4
- See Also:
- 
Field Summary
- 
Constructor SummaryConstructorsConstructorDescriptionCharSequenceReader(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.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Close resets the file back to the start and removes any marked position.voidmark(int readAheadLimit) Mark the current position.booleanMark is supported (returns true).intread()Reads a single character.intread(char[] array, int offset, int length) Reads the specified number of characters into the array.booleanready()Tells whether this stream is ready to be read.voidreset()Reset the reader to the last marked position (or the beginning if mark has not been called).longskip(long n) Skip the specified number of characters.toString()Gets a String representation of the underlying character sequence.
- 
Constructor Details- 
CharSequenceReaderConstructs a new instance with the specified character sequence.- Parameters:
- charSequence- The character sequence, may be- null
 
- 
CharSequenceReaderConstructs a new instance with a portion of the specified character sequence.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 IndexOutOfBoundsExceptionto be thrown. Instead, if the character sequence grows smaller than the start index, this instance will act as if all characters have been read.- Parameters:
- charSequence- The character sequence, may be- null
- start- The start index in the character sequence, inclusive
- Throws:
- IllegalArgumentException- if the start index is negative
- Since:
- 2.7
 
- 
CharSequenceReaderConstructs a new instance with a portion of the specified character sequence.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 IndexOutOfBoundsExceptionto 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.- Parameters:
- charSequence- The character sequence, may be- null
- start- The start index in the character sequence, inclusive
- end- The end index in the character sequence, exclusive
- Throws:
- IllegalArgumentException- if the start index is negative, or if the end index is smaller than the start index
- Since:
- 2.7
 
 
- 
- 
Method Details- 
closeClose resets the file back to the start and removes any marked position.
- 
markMark the current position.
- 
markSupportedMark is supported (returns true).- Overrides:
- markSupportedin class- Reader
- Returns:
- true
 
- 
readReads a single character.
- 
readReads the specified number of characters into the array.
- 
readyTells whether this stream is ready to be read.
- 
resetReset the reader to the last marked position (or the beginning if mark has not been called).
- 
skipSkip the specified number of characters.
- 
toStringGets a String representation of the underlying character sequence.
 
-