-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
58 lines (46 loc) · 1.23 KB
/
Main.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
49
50
51
52
53
54
55
56
57
58
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class Main {
public static void freader() throws IOException{
BufferedReader br = new BufferedReader(new FileReader("teste.in"));
try {
StringBuilder sb = new StringBuilder();
String line = "";
while (line != null) {
sb.append(line);
sb.append("\n");
line = br.readLine();
if(line == null)
break;
System.out.println(line);
}
} finally {
br.close();
}
}
public static void fwriter(String arg) {
try {
String content = arg;
File file = new File("teste.out");
// if file doesnt exists, then create it
if (!file.exists()) {
file.createNewFile();
}
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
bw.write(content);
bw.close();
System.out.println("Done");
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String args[]) throws IOException{
Main.freader();
}
}