Skip to content

Instantly share code, notes, and snippets.

@debop
Created April 29, 2013 02:45
bufferedStream
@Test
public void bufferedStreams() throws Exception {
Path path = Paths.get("channel.txt");
try (BufferedWriter writer = Files.newBufferedWriter(path, UTF8, StandardOpenOption.CREATE, StandardOpenOption.APPEND)) {
for (int i = 0; i < 100; i++) {
writer.write(TEST_TEXT);
}
writer.flush();
}
List<String> lines = Files.readAllLines(path, Charset.forName("UTF-8"));
for (String line : lines)
System.out.println(line);
Files.deleteIfExists(path);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment