Class CharSource.StringCharSource

Direct Known Subclasses:
CharSource.EmptyCharSource
Enclosing class:
CharSource

private static class CharSource.StringCharSource extends CharSource.CharSequenceCharSource
Subclass specialized for string instances.

Since Strings are immutable and built into the jdk we can optimize some operations

  • Constructor Details

    • StringCharSource

      protected StringCharSource(String seq)
  • Method Details

    • openStream

      public Reader openStream()
      Description copied from class: CharSource
      Opens a new Reader for reading from this source. This method returns a new, independent reader each time it is called.

      The caller is responsible for ensuring that the returned reader is closed.

      Overrides:
      openStream in class CharSource.CharSequenceCharSource
    • copyTo

      public long copyTo(Appendable appendable) throws IOException
      Description copied from class: CharSource
      Appends the contents of this source to the given Appendable (such as a Writer). Does not close appendable if it is Closeable.
      Overrides:
      copyTo in class CharSource
      Returns:
      the number of characters copied
      Throws:
      IOException - if an I/O error occurs while reading from this source or writing to appendable
    • copyTo

      public long copyTo(CharSink sink) throws IOException
      Description copied from class: CharSource
      Copies the contents of this source to the given sink.
      Overrides:
      copyTo in class CharSource
      Returns:
      the number of characters copied
      Throws:
      IOException - if an I/O error occurs while reading from this source or writing to sink