-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
57 lines (44 loc) · 1.7 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
//package AddressBook;
//import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.*;
//import java.util.LinkedHashMap;
//import java.util.Map;
//import java.util.Scanner;
public class Main {
public static void main(String[] args) {
try {
File f = new File(args[0]);
//File f = new File("in.txt");
BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(f), "utf-8"));
BufferedWriter out = new BufferedWriter(new FileWriter(args[1]));
//File f2= new File("2.txt");
//BufferedWriter out = new BufferedWriter(new FileWriter(f2));
String l = null;
JSONArray array = new JSONArray();
while ((l = r.readLine()) != null )
{
String address = l;
String split[] = address.split("!");
// System.out.println(AddressUtil.addressResolutionVersion2(split[1],1));
if (split[0].equals("1")){
array.put(Resolution.addressResolution(split[1],'1'));
}else if (split[0].equals("2")){
array.put(Resolution.addressResolution(split[1],'2'));
}else {
array.put(Resolution.addressResolution(split[1],'3'));
}
}
out.write(array.toString());
out.close();
r.close();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}