Package org.codehaus.groovy.util
Class CharSequenceReader
java.lang.Object
java.io.Reader
org.codehaus.groovy.util.CharSequenceReader
- All Implemented Interfaces:
- Closeable,- Serializable,- AutoCloseable,- Readable
Reader implementation that can read from String, StringBuffer,
 StringBuilder, CharBuffer or GString.
 
 Note: Supports mark(int) and reset().
 
Note: This class is mostly a copy from Commons IO and is intended for internal Groovy usage only. It may be deprecated and removed from Groovy at a faster pace than other classes. If you need this functionality in your Groovy programs, we recommend using the Commons IO equivalent directly.
- See Also:
- 
Field Summary
- 
Constructor SummaryConstructorsConstructorDescriptionCharSequenceReader(CharSequence charSequence) Construct a new instance with the specified character sequence.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Close resets the reader back to the start and removes any marked position.voidmark(int readAheadLimit) Mark the current position.booleanMark is supported (returns true).intread()Read a single character.intread(char[] array, int offset, int length) Read the specified number of characters into the array.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()Return a String representation of the underlying character sequence.Methods inherited from class java.io.ReadernullReader, read, read, ready, transferTo
- 
Constructor Details- 
CharSequenceReaderConstruct a new instance with the specified character sequence.- Parameters:
- charSequence- The character sequence, may be- null
 
 
- 
- 
Method Details- 
closepublic void close()Close resets the reader back to the start and removes any marked position.
- 
markpublic void mark(int readAheadLimit) Mark the current position.
- 
markSupportedpublic boolean markSupported()Mark is supported (returns true).- Overrides:
- markSupportedin class- Reader
- Returns:
- true
 
- 
readpublic int read()Read a single character.
- 
readpublic int read(char[] array, int offset, int length) Read the specified number of characters into the array.
- 
resetpublic void reset()Reset the reader to the last marked position (or the beginning if mark has not been called).
- 
skippublic long skip(long n) Skip the specified number of characters.
- 
toStringReturn a String representation of the underlying character sequence.
 
-