Package com.google.common.io
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 Summary
Fields Modifier and Type Field Description (package private) java.nio.charset.Charset
charset
-
Constructor Summary
Constructors Constructor Description AsByteSource(java.nio.charset.Charset charset)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CharSource
asCharSource(java.nio.charset.Charset charset)
Returns aCharSource
view of this byte source that decodes bytes read from this source as characters using the givenCharset
.java.io.InputStream
openStream()
Opens a newInputStream
for reading from this source.java.lang.String
toString()
-
Methods inherited from class com.google.common.io.ByteSource
concat, concat, concat, contentEquals, copyTo, copyTo, empty, hash, isEmpty, openBufferedStream, read, read, size, sizeIfKnown, slice, wrap
-
-
-
-
Method Detail
-
asCharSource
public CharSource asCharSource(java.nio.charset.Charset charset)
Description copied from class:ByteSource
Returns aCharSource
view of this byte source that decodes bytes read from this source as characters using the givenCharset
.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 originalByteSource
is returned, rather than round-trip encoding. Subclasses that override this method should behave the same way.- Overrides:
asCharSource
in classByteSource
-
openStream
public java.io.InputStream openStream() throws java.io.IOException
Description copied from class:ByteSource
Opens a newInputStream
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 classByteSource
- 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 classjava.lang.Object
-
-