OnJava8-Examples/io/FileOutputShortcut.out
2015-04-20 23:01:41 -07:00

22 lines
733 B
Plaintext

1: //: io/FileOutputShortcut.java
2: import java.io.*;
3:
4: public class FileOutputShortcut {
5: static String file = "FileOutputShortcut.out";
6: public static void main(String[] args)
7: throws IOException {
8: BufferedReader in = new BufferedReader(
9: new StringReader(
10: BufferedInputFile.read("FileOutputShortcut.java")));
11: // Here's the shortcut:
12: PrintWriter out = new PrintWriter(file);
13: int lineCount = 1;
14: String s;
15: while((s = in.readLine()) != null )
16: out.println(lineCount++ + ": " + s);
17: out.close();
18: // Show the stored file:
19: System.out.println(BufferedInputFile.read(file));
20: }
21: } /* (Execute to see output) *///:~