Package org.codehaus.groovy.util
Class CharSequenceReader
- java.lang.Object
- 
- java.io.Reader
- 
- org.codehaus.groovy.util.CharSequenceReader
 
 
- 
- All Implemented Interfaces:
- java.io.Closeable,- java.io.Serializable,- java.lang.AutoCloseable,- java.lang.Readable
 
 public class CharSequenceReader extends java.io.Reader implements java.io.SerializableReaderimplementation that can read from String, StringBuffer, StringBuilder, CharBuffer or GString.Note: Supports mark(int)andreset().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:
- Serialized Form
 
- 
- 
Constructor SummaryConstructors Constructor Description CharSequenceReader(java.lang.CharSequence charSequence)Construct a new instance with the specified character sequence.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close resets the reader back to the start and removes any marked position.voidmark(int readAheadLimit)Mark the current position.booleanmarkSupported()Mark is supported (returns true).intread()Read a single character.intread(char[] array, int offset, int length)Read the sepcified 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.java.lang.StringtoString()Return a String representation of the underlying character sequence.
 
- 
- 
- 
Method Detail- 
closepublic void close() Close resets the reader back to the start and removes any marked position.- Specified by:
- closein interface- java.lang.AutoCloseable
- Specified by:
- closein interface- java.io.Closeable
- Specified by:
- closein class- java.io.Reader
 
 - 
markpublic void mark(int readAheadLimit) Mark the current position.- Overrides:
- markin class- java.io.Reader
- Parameters:
- readAheadLimit- ignored
 
 - 
markSupportedpublic boolean markSupported() Mark is supported (returns true).- Overrides:
- markSupportedin class- java.io.Reader
- Returns:
- true
 
 - 
readpublic int read() Read a single character.- Overrides:
- readin class- java.io.Reader
- Returns:
- the next character from the character sequence or -1 if the end has been reached.
 
 - 
readpublic int read(char[] array, int offset, int length)Read the sepcified number of characters into the array.- Specified by:
- readin class- java.io.Reader
- Parameters:
- array- The array to store the characters in
- offset- The starting position in the array to store
- length- The maximum number of characters to read
- Returns:
- The number of characters read or -1 if there are no more
 
 - 
resetpublic void reset() Reset the reader to the last marked position (or the beginning if mark has not been called).- Overrides:
- resetin class- java.io.Reader
 
 - 
skippublic long skip(long n) Skip the specified number of characters.- Overrides:
- skipin class- java.io.Reader
- Parameters:
- n- The number of characters to skip
- Returns:
- The actual number of characters skipped
 
 - 
toStringpublic java.lang.String toString() Return a String representation of the underlying character sequence.- Overrides:
- toStringin class- java.lang.Object
- Returns:
- The contents of the character sequence
 
 
- 
 
-