-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.java
More file actions
57 lines (51 loc) · 1.74 KB
/
Copy pathMain.java
File metadata and controls
57 lines (51 loc) · 1.74 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
package ThoughtWorks;
import ThoughtWorks.tools.Checking;
import java.io.File;
import java.io.FileNotFoundException;
import java.net.URISyntaxException;
import java.util.Scanner;
/**启动位置, 接收任意长度参数*/
public class Main {
/**
* @param fileNames 文件名参数,可以是绝对路径或根目录相对路径*/
public static void main(String[] fileNames) {
File raw = null;
if (fileNames.length <= 0) {
try {
raw = new File(Main.class.getResource("raw.txt").toURI());
} catch (URISyntaxException e) {
e.printStackTrace();
}
test(raw);
} else {
int i = 0;
while (i < fileNames.length) {
try {
raw = new File(Main.class.getResource(fileNames[i]).toURI());
} catch (URISyntaxException e) {
e.printStackTrace();
raw = new File(fileNames[i]);
}
test(raw);
i++;
}
}
}
/**调用相关类对文本数据进行测试*/
private static void test(File raw) {
Scanner scanner = null;
try {
scanner = new Scanner(raw);
WatchCenter watchCenter = new WatchCenter();
watchCenter.readRecord(scanner);
System.out.println(watchCenter.getInfo(2));
System.out.println(watchCenter.getInfo(4));
System.out.println(watchCenter.getInfo(100));
} catch (FileNotFoundException e) {
e.printStackTrace();
}finally {
if (scanner != null)
scanner.close();
}
}
}