-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIOTest.java~
48 lines (43 loc) · 1.15 KB
/
IOTest.java~
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
40
41
42
43
44
45
46
47
48
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package iotest;
import java.io.*;
import java.util.Scanner;
/**
*
* @author nicholaszetzl
*/
public class IOTest {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException{
File file = new File("Text");
FileOutputStream fos = new FileOutputStream(file, true);
PrintWriter pw = new PrintWriter(fos);
Scanner s = new Scanner(System.in);
int count = 0;
while (count < 5) {
String line = s.nextLine();
pw.println(line);
count++;
}
s.close();
pw.close();
FileReader fr = new FileReader(file);
BufferedReader bfr = new BufferedReader(fr);
String st;
while (true) {
st = bfr.readLine();
if (st == null) {
break;
} else {
System.out.println(s);
}
}
bfr.close();
}
}