aboutsummaryrefslogtreecommitdiff
path: root/CS2452/assign2/src/P1.java
blob: 3580cf9807dc69302f690b0d55280f2c3ece4dc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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]);
		}
	
				

		
	}
}