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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.common.io.ByteSource
ByteSource.AsCharSource
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.nio.charset.Charsetcharset
-
Constructor Summary
Constructors Constructor Description AsByteSource(java.nio.charset.Charset charset)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CharSourceasCharSource(java.nio.charset.Charset charset)Returns aCharSourceview of this byte source that decodes bytes read from this source as characters using the givenCharset.java.io.InputStreamopenStream()Opens a newInputStreamfor reading from this source.java.lang.StringtoString()-
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:ByteSourceReturns aCharSourceview 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 originalByteSourceis returned, rather than round-trip encoding. Subclasses that override this method should behave the same way.- Overrides:
asCharSourcein classByteSource
-
openStream
public java.io.InputStream openStream() throws java.io.IOExceptionDescription copied from class:ByteSourceOpens a newInputStreamfor 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:
openStreamin classByteSource- Throws:
java.io.IOException- if an I/O error occurs while opening the stream
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-