Tutorial by Examples

Reading the content of an InputStream as a byte array: // Reading from a file try (InputStream in = new FileInputStream("in.dat")) { byte[] content = ByteStreams.toByteArray(in); // do something with content } Copying an InputStream to an OutputStream: // Copying the content f...
Reading the content of a Reader as a String: // Reading from a file try (Reader reader = new FileReader("in.txt")) { String content = CharStreams.toString(reader); // do something with content } Reading the content of a Reader as a list of line contents: try (Reader reader = n...
Sources and sinks are objects that know how to open streams. BytesCharsReadingByteSourceCharSourceWritingByteSinkCharSink Creating sources and sinks Note: for all examples, consider UTF_8 as if the following import is set: import static java.nio.charset.StandardCharsets.UTF_8; Reading from a ...

Page 1 of 1