Class CharSource.AsByteSource

  • Enclosing class:
    CharSource

    private final class CharSource.AsByteSource
    extends ByteSource
    A byte source that reads chars from this source and encodes them as bytes using a charset.
    • Field Detail

      • charset

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

      • AsByteSource

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

      • asCharSource

        public CharSource asCharSource​(java.nio.charset.Charset charset)
        Description copied from class: ByteSource
        Returns a CharSource view of this byte source that decodes bytes read from this source as characters using the given Charset.

        If CharSource.asByteSource(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 ByteSource is returned, rather than round-trip encoding. Subclasses that override this method should behave the same way.

        Overrides:
        asCharSource in class ByteSource
      • openStream

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

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

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

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