? CharSequenceReader

java.lang.Object
java.io.Reader
org.apache.commons.io.input.CharSequenceReader
????????:
Closeable, Serializable, AutoCloseable, Readable

public class CharSequenceReader extends Reader implements Serializable
Reader implementation that can read from String, StringBuffer, StringBuilder or CharBuffer.

Note: Supports mark(int) and reset().

???????:
1.4
????:
  • ????

    ??????? java.io.Reader

    lock
  • ?????

    ???
    ???
    ??
    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.
  • ????

    ??????
    ??
    ??
    void
    Close resets the file back to the start and removes any marked position.
    void
    mark(int readAheadLimit)
    Mark the current position.
    boolean
    Mark is supported (returns true).
    int
    Read a single character.
    int
    read(char[] array, int offset, int length)
    Read the specified number of characters into the array.
    boolean
    Tells whether this stream is ready to be read.
    void
    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.
    Return a String representation of the underlying character sequence.

    ??????? java.io.Reader

    nullReader, read, read, transferTo
  • ???????

    • CharSequenceReader

      public CharSequenceReader(CharSequence charSequence)
      Constructs a new instance with the specified character sequence.
      ??:
      charSequence - The character sequence, may be null
    • CharSequenceReader

      public CharSequenceReader(CharSequence charSequence, int start)
      Constructs 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 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, inclusive
      ??:
      IllegalArgumentException - if the start index is negative
      ???????:
      2.7
    • CharSequenceReader

      public CharSequenceReader(CharSequence charSequence, int start, int end)
      Constructs 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 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, inclusive
      end - The end index in the character sequence, exclusive
      ??:
      IllegalArgumentException - if the start index is negative, or if the end index is smaller than the start index
      ???????:
      2.7
  • ??????

    • close

      public void close()
      Close resets the file back to the start and removes any marked position.
      ???:
      close ???? AutoCloseable
      ???:
      close ???? Closeable
      ???:
      close ??? Reader
    • ready

      public boolean ready()
      Tells whether this stream is ready to be read.
      ??:
      ready ??? Reader
      ??:
      true if more characters from the character sequence are available, or false otherwise.
    • mark

      public void mark(int readAheadLimit)
      Mark the current position.
      ??:
      mark ??? Reader
      ??:
      readAheadLimit - ignored
    • markSupported

      public boolean markSupported()
      Mark is supported (returns true).
      ??:
      markSupported ??? Reader
      ??:
      true
    • read

      public int read()
      Read a single character.
      ??:
      read ??? Reader
      ??:
      the next character from the character sequence or -1 if the end has been reached.
    • read

      public int read(char[] array, int offset, int length)
      Read the specified number of characters into the array.
      ???:
      read ??? Reader
      ??:
      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
      ??:
      The number of characters read or -1 if there are no more
    • reset

      public void reset()
      Reset the reader to the last marked position (or the beginning if mark has not been called).
      ??:
      reset ??? Reader
    • skip

      public long skip(long n)
      Skip the specified number of characters.
      ??:
      skip ??? Reader
      ??:
      n - The number of characters to skip
      ??:
      The actual number of characters skipped
    • toString

      public String toString()
      Return a String representation of the underlying character sequence.
      ??:
      toString ??? Object
      ??:
      The contents of the character sequence