Package com.google.common.io
Class ByteSource.AsCharSource
java.lang.Object
com.google.common.io.CharSource
com.google.common.io.ByteSource.AsCharSource
- Enclosing class:
ByteSource
A char source that reads bytes from this source and decodes them as characters using a charset.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasByteSource(Charset charset) Returns aByteSourceview of this char source that encodes chars read from this source as bytes using the givenCharset.Opens a newReaderfor reading from this source.read()Reads the contents of this source as a string.toString()Methods inherited from class com.google.common.io.CharSource
concat, concat, concat, copyTo, copyTo, empty, forEachLine, isEmpty, length, lengthIfKnown, lines, openBufferedStream, readFirstLine, readLines, readLines, wrap
-
Field Details
-
charset
-
-
Constructor Details
-
AsCharSource
AsCharSource(Charset charset)
-
-
Method Details
-
asByteSource
Description copied from class:CharSourceReturns aByteSourceview of this char source that encodes chars read from this source as bytes using the givenCharset.If
ByteSource.asCharSource(java.nio.charset.Charset)is called on the returned source with the same charset, the default implementation of this method will ensure that the originalCharSourceis returned, rather than round-trip encoding. Subclasses that override this method should behave the same way.- Overrides:
asByteSourcein classCharSource
-
openStream
Description copied from class:CharSourceOpens a newReaderfor reading from this source. This method returns a new, independent reader each time it is called.The caller is responsible for ensuring that the returned reader is closed.
- Specified by:
openStreamin classCharSource- Throws:
IOException- if an I/O error occurs while opening the reader
-
read
Description copied from class:CharSourceReads the contents of this source as a string.- Overrides:
readin classCharSource- Throws:
IOException- if an I/O error occurs while reading from this source
-
toString
-