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
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasCharSource
(Charset charset) Returns aCharSource
view of this byte source that decodes bytes read from this source as characters using the givenCharset
.Opens a newInputStream
for reading from this source.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
-
Field Details
-
charset
-
-
Constructor Details
-
AsByteSource
AsByteSource(Charset charset)
-
-
Method Details
-
asCharSource
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
Description copied from class:ByteSource
Opens a newInputStream
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 classByteSource
- Throws:
IOException
- if an I/O error occurs while opening the stream
-
toString
-