Class CharSource.AsByteSource

java.lang.Object
com.google.common.io.ByteSource
com.google.common.io.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 Details

  • Constructor Details

    • AsByteSource

      AsByteSource(Charset charset)
  • Method Details

    • asCharSource

      public CharSource asCharSource(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 InputStream openStream() throws IOException
      Description copied from class: ByteSource
      Opens a new InputStream for reading from this source. This method returns 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:
      IOException - if an I/O error occurs while opening the stream
    • toString

      public String toString()
      Overrides:
      toString in class Object