From b4dbd2cfa724476162fa6d35941a5d7cdc9c9524 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Mon, 18 Feb 2019 08:10:10 -0500 Subject: Adds all assignments not previously in a git repo --- CS2452/assign2/src/P1.java | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 CS2452/assign2/src/P1.java (limited to 'CS2452/assign2/src') diff --git a/CS2452/assign2/src/P1.java b/CS2452/assign2/src/P1.java new file mode 100644 index 0000000..3580cf9 --- /dev/null +++ b/CS2452/assign2/src/P1.java @@ -0,0 +1,39 @@ +import java.io.*; + +class P1 +{ + + public static void main(String[] args) + { + String str = null; + BufferedReader br; + br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = null; + + try + { + File file = new File(args[0]); + + if (! file.exists()) + { + file.createNewFile(); + } + + bw = new BufferedWriter(new FileWriter(file)); + while(true) + { + str = br.readLine(); + bw.write(str); + bw.newLine(); + bw.flush(); + } + } catch(Exception e) + { + System.out.printf("Unable to write to file %s\n", args[0]); + } + + + + + } +} -- cgit v1.1