OnJava8-Examples/iostreams/BasicFileOutput.java
2017-05-17 21:38:05 -06:00

27 lines
816 B
Java

// iostreams/BasicFileOutput.java
// (c)2017 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://OnJava8.com for more book information.
// {VisuallyInspectOutput}
import java.io.*;
public class BasicFileOutput {
static String file = "BasicFileOutput.dat";
public static void main(String[] args) {
try(
BufferedReader in = new BufferedReader(
new StringReader(
BufferedInputFile.read(
"BasicFileOutput.java")));
PrintWriter out = new PrintWriter(
new BufferedWriter(new FileWriter(file)))
) {
in.lines().forEach(out::println);
} catch(IOException e) {
throw new RuntimeException(e);
}
// Show the stored file:
System.out.println(BufferedInputFile.read(file));
}
}