|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.google.common.io.CharSource
public abstract class CharSource
A readable source of characters, such as a text file. Unlike a Reader, a
CharSource is not an open, stateful stream of characters that can be read and closed.
Instead, it is an immutable supplier of InputStream instances.
CharSource provides two kinds of methods:
Several methods in this class, such as readLines(), break the contents of the
source into lines. Like BufferedReader, these methods break lines on any of \n,
\r or \r\n, do not include the line separator in each line and do not consider
there to be an empty line at the end if the contents are terminated with a line separator.
Any ByteSource containing text encoded with a specific character
encoding may be viewed as a CharSource using ByteSource.asCharSource(Charset).
| Constructor Summary | |
|---|---|
CharSource()
|
|
| Method Summary | |
|---|---|
long |
copyTo(java.lang.Appendable appendable)
Appends the contents of this source to the given Appendable (such as a Writer). |
long |
copyTo(CharSink sink)
Copies the contents of this source to the given sink. |
java.io.BufferedReader |
openBufferedStream()
Opens a new BufferedReader for reading from this source. |
abstract java.io.Reader |
openStream()
Opens a new Reader for reading from this source. |
java.lang.String |
read()
Reads the contents of this source as a string. |
java.lang.String |
readFirstLine()
Reads the first link of this source as a string. |
ImmutableList<java.lang.String> |
readLines()
Reads all the lines of this source as a list of strings. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CharSource()
| Method Detail |
|---|
public abstract java.io.Reader openStream()
throws java.io.IOException
Reader for reading from this source. This method should return a new,
independent reader each time it is called.
The caller is responsible for ensuring that the returned reader is closed.
java.io.IOException - if an I/O error occurs in the process of opening the reader
public java.io.BufferedReader openBufferedStream()
throws java.io.IOException
BufferedReader for reading from this source. This method should return a
new, independent reader each time it is called.
The caller is responsible for ensuring that the returned reader is closed.
java.io.IOException - if an I/O error occurs in the process of opening the reader
public long copyTo(java.lang.Appendable appendable)
throws java.io.IOException
Appendable (such as a Writer).
Does not close appendable if it is Closeable.
java.io.IOException - if an I/O error occurs in the process of reading from this source or
writing to appendable
public long copyTo(CharSink sink)
throws java.io.IOException
java.io.IOException - if an I/O error occurs in the process of reading from this source or
writing to sink
public java.lang.String read()
throws java.io.IOException
java.io.IOException - if an I/O error occurs in the process of reading from this source
@Nullable
public java.lang.String readFirstLine()
throws java.io.IOException
null if this source is empty.
Like BufferedReader, this method breaks lines on any of \n, \r or
\r\n, does not include the line separator in the returned line and does not consider
there to be an extra empty line at the end if the content is terminated with a line separator.
java.io.IOException - if an I/O error occurs in the process of reading from this source
public ImmutableList<java.lang.String> readLines()
throws java.io.IOException
Like BufferedReader, this method breaks lines on any of \n, \r or
\r\n, does not include the line separator in the returned lines and does not consider
there to be an extra empty line at the end if the content is terminated with a line separator.
java.io.IOException - if an I/O error occurs in the process of reading from this source
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||