Class ByteSource.AsCharSource

  • Enclosing class:
    ByteSource

    private final class ByteSource.AsCharSource
    extends CharSource
    A char source that reads bytes from this source and decodes them as characters using a charset.
    • Field Detail

      • charset

        final java.nio.charset.Charset charset
    • Constructor Detail

      • AsCharSource

        AsCharSource​(java.nio.charset.Charset charset)
    • Method Detail

      • asByteSource

        public ByteSource asByteSource​(java.nio.charset.Charset charset)
        Description copied from class: CharSource
        Returns a ByteSource view of this char source that encodes chars read from this source as bytes using the given Charset.

        If ByteSource.asCharSource(java.nio.charset.Charset) is called on the returned source with the same charset, the default implementation of this method will ensure that the original CharSource is returned, rather than round-trip encoding. Subclasses that override this method should behave the same way.

        Overrides:
        asByteSource in class CharSource
      • openStream

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

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

        Specified by:
        openStream in class CharSource
        Throws:
        java.io.IOException - if an I/O error occurs in the process of opening the reader
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object