| java.lang.Object | |
| ↳ | com.google.gdata.util.common.io.CharStreams |
Provides utility methods for working with character streams.
All method parameters must be non-null unless documented otherwise.
Some of the methods in this class take arguments with a generic type of
Readable & Closeable. A java.io.Reader implements both of
those interfaces. Similarly for Appendable & Closeable and
java.io.Writer.
| Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| int | BUF_SIZE | ||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Returns a Writer that sends all output to the given Appendable
target.
| |||||||||||
Copies all characters between the Readable and Appendable
objects.
| |||||||||||
Opens Readable and Appendable objects from the
given factories, copies all characters between the two, and closes
them.
| |||||||||||
Opens a Readable object from the supplier, copies all characters
to the Appendable object, and closes the input.
| |||||||||||
Joins multiple Reader suppliers into a single supplier.
| |||||||||||
Varargs form of
join(Iterable). | |||||||||||
Returns a factory that will supply instances of InputStreamReader,
using the given InputStream factory and character set.
| |||||||||||
Returns a factory that will supply instances of StringReader that
read a string value.
| |||||||||||
Returns a factory that will supply instances of OutputStreamWriter,
using the given OutputStream factory and character set.
| |||||||||||
Reads the first line from a Readable & Closeable object
supplied by a factory.
| |||||||||||
Reads all of the lines from a Readable & Closeable object
supplied by a factory.
| |||||||||||
Reads all of the lines from a Readable object.
| |||||||||||
Streams lines from a Readable and Closeable object
supplied by a factory, stopping when our callback returns false, or we
have read all of the lines.
| |||||||||||
Discards
n characters of data from the reader. | |||||||||||
Returns the characters from a Readable & Closeable object
supplied by a factory as a String.
| |||||||||||
Reads all characters from a Readable object into a String.
| |||||||||||
Writes a character sequence (such as a string) to an appendable
object from the given supplier.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
Returns a Writer that sends all output to the given Appendable target. Closing the writer will close the target if it is Closeable, and flushing the writer will flush the target if it is java.io.Flushable.
| target | The object to which output will be sent |
|---|
Copies all characters between the Readable and Appendable objects. Does not close or flush either object.
| from | The object to read from |
|---|---|
| to | The object to write to |
| IOException | if an I/O error occurs |
|---|
Opens Readable and Appendable objects from the given factories, copies all characters between the two, and closes them.
| from | The input factory |
|---|---|
| to | The output factory |
| IOException | if an I/O error occurs |
|---|
Opens a Readable object from the supplier, copies all characters to the Appendable object, and closes the input. Does not close or flush the output.
| from | The input factory |
|---|---|
| to | The object to write to |
| IOException | if an I/O error occurs |
|---|
Joins multiple Reader suppliers into a single supplier. Reader returned from the supplier will contain the concatenated data from the readers of the underlying suppliers.
Reading from the joined reader will throw a NullPointerException if any of the suppliers are null or return null.
Only one underlying reader will be open at a time. Closing the joined reader will close the open underlying reader.
| suppliers | The suppliers to concatenate |
|---|
Varargs form of join(Iterable).
| suppliers |
|---|
Returns a factory that will supply instances of InputStreamReader, using the given InputStream factory and character set.
| in | The factory that will be used to open input streams |
|---|---|
| charset | The character set used to decode the input stream |
Returns a factory that will supply instances of StringReader that read a string value.
| value | The string to read |
|---|
Returns a factory that will supply instances of OutputStreamWriter, using the given OutputStream factory and character set.
| out | The factory that will be used to open output streams |
|---|---|
| charset | The character set used to encode the output stream |
Reads the first line from a Readable & Closeable object supplied by a factory. The line does not include line-termination characters, but does include other leading and trailing whitespace.
| supplier | The factory to read from |
|---|
| IOException | if an I/O error occurs |
|---|
Reads all of the lines from a Readable & Closeable object supplied by a factory. The lines do not include line-termination characters, but do include other leading and trailing whitespace.
| supplier | The factory to read from |
|---|
| IOException | if an I/O error occurs |
|---|
Reads all of the lines from a Readable object. The lines do not include line-termination characters, but do include other leading and trailing whitespace.
Does not close the Readable. If reading files or resources you
should use the Files#readLines and Resources#readLines
methods.
| r | The object to read from |
|---|
| IOException | if an I/O error occurs |
|---|
Streams lines from a Readable and Closeable object supplied by a factory, stopping when our callback returns false, or we have read all of the lines.
| supplier | The factory to read from |
|---|---|
| callback | The LineProcessor to use to handle the lines |
| IOException | if an I/O error occurs |
|---|
Discards n characters of data from the reader. This method
will block until the full amount has been skipped. Does not close the
reader.
| reader | The reader to read from |
|---|---|
| n | The number of characters to skip |
| EOFException | if this stream reaches the end before skipping all the bytes |
|---|---|
| IOException | if an I/O error occurs |
Returns the characters from a Readable & Closeable object supplied by a factory as a String.
| supplier | The factory to read from |
|---|
| IOException | if an I/O error occurs |
|---|
Reads all characters from a Readable object into a String.
Does not close the Readable.
| r | The object to read from |
|---|
| IOException | if an I/O error occurs |
|---|
Writes a character sequence (such as a string) to an appendable object from the given supplier.
| from | The character sequence to write |
|---|---|
| to | The output supplier |
| IOException | if an I/O error occurs |
|---|