Class CharStreams
- java.lang.Object
-
- com.impossibl.postgres.utils.guava.CharStreams
-
public final class CharStreams extends 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. AReaderimplements both of those interfaces. Similarly forAppendable & CloseableandWriter.- Since:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCharStreams.LimitedReader
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static longcopy(Readable from, Appendable to)Copies all characters between theReadableandAppendableobjects.static Readerlimit(Reader in, long n)static voidskipFully(Reader reader, long n)Discardsncharacters of data from the reader.static StringtoString(Readable r)
-
-
-
Method Detail
-
copy
public static long copy(Readable from, Appendable to) throws IOException
Copies all characters between theReadableandAppendableobjects. 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:
IOException- if an I/O error occurs
-
toString
public static String toString(Readable r) throws IOException
- Parameters:
r- the object to read from- Returns:
- a string containing all the characters
- Throws:
IOException- if an I/O error occurs
-
skipFully
public static void skipFully(Reader reader, long n) throws IOException
Discardsncharacters 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:
EOFException- if this stream reaches the end before skipping all the bytesIOException- if an I/O error occurs
-
-