-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasicio.java
More file actions
58 lines (50 loc) · 1.36 KB
/
Copy pathbasicio.java
File metadata and controls
58 lines (50 loc) · 1.36 KB
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.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class basicio {
public static void main(String[] args) {
String pathRoot = "./";
String relRoot = "test.in";
String in = pathRoot + relRoot;
//Length of the file extension
int extLength = 2;
String out = in.substring(0, in.length() - extLength)+"out";
BufferedReader r = null;
BufferedWriter w = null;
int testCount = 1;
int totalTests = Integer.valueOf(r.readLine());
try {
r = new BufferedReader(new FileReader(in));
w = new BufferedWriter(new FileWriter(out));
String line;
while((line = r.readLine()) != null) {
long start = System.currentTimeMillis();
String outcome = getOutcome(line);
long end = System.currentTimeMillis();
System.out.println(testCount + " - Time : " + (end -start));
w.write("Case #" + testCount + ": " + outcome);
w.newLine();
testCount++;
}
}
catch (IOException e){
e.printStackTrace();
}
finally {
try{
r.close();
if(w != null) {
w.flush();
w.close();
}
} catch (IOException e){
e.printStackTrace();
}
}
}
public static String getOutcome(String input) {
return input;
}
}