Class CharStreams
- java.lang.Object
-
- com.impossibl.postgres.utils.guava.CharStreams
-
public final class CharStreams extends java.lang.Object
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
. AReader
implements both of those interfaces. Similarly forAppendable & Closeable
andWriter
.- Since:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CharStreams.LimitedReader
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
copy(java.lang.Readable from, java.lang.Appendable to)
Copies all characters between theReadable
andAppendable
objects.static java.io.Reader
limit(java.io.Reader in, long n)
static void
skipFully(java.io.Reader reader, long n)
Discardsn
characters of data from the reader.static java.lang.String
toString(java.lang.Readable r)
Reads all characters from aReadable
object into aString
.
-
-
-
Method Detail
-
copy
public static long copy(java.lang.Readable from, java.lang.Appendable to) throws java.io.IOException
Copies all characters between theReadable
andAppendable
objects. Does not close or flush either object.- Parameters:
from
- the object to read fromto
- the object to write to- Returns:
- the number of characters copied
- Throws:
java.io.IOException
- if an I/O error occurs
-
toString
public static java.lang.String toString(java.lang.Readable r) throws java.io.IOException
Reads all characters from aReadable
object into aString
. Does not close theReadable
.- Parameters:
r
- the object to read from- Returns:
- a string containing all the characters
- Throws:
java.io.IOException
- if an I/O error occurs
-
skipFully
public static void skipFully(java.io.Reader reader, long n) throws java.io.IOException
Discardsn
characters of data from the reader. This method will block until the full amount has been skipped. Does not close the reader.- Parameters:
reader
- the reader to read fromn
- the number of characters to skip- Throws:
java.io.EOFException
- if this stream reaches the end before skipping all the bytesjava.io.IOException
- if an I/O error occurs
-
limit
public static java.io.Reader limit(java.io.Reader in, long n)
-
-