-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompare.java
More file actions
60 lines (56 loc) · 1.79 KB
/
Compare.java
File metadata and controls
60 lines (56 loc) · 1.79 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
59
60
package compareResult;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import org.apache.commons.lang.StringUtils;
public class Compare {
public void ConvertStringFile(String name){
File t = new File(name);
try {
InputStreamReader reader = new InputStreamReader(new FileInputStream(t));
BufferedReader br = new BufferedReader(reader);
String outputname = "out" + name;
System.out.println(outputname);
File write = new File(outputname);
write.createNewFile();
BufferedWriter out = new BufferedWriter(new FileWriter(write));
String line = "";
line = br.readLine();
String concat = "";
while(line != null){
String[] word = line.split(",");
for(int i = 0; i < word.length; i++){
word[i] = StringUtils.substringBefore(word[i], "]");
word[i] = word[i].substring(1, word[i].length());
}
for(int i = 0; i < word.length; i++){
out.write(word[i]+"\r\n");
System.out.println(word[i]);
}
line = br.readLine();
}
out.flush();
out.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args){
// String t = "[\"compilations\"],[\"bewailed\"],[\"horology\"],[\"map\"]";
// System.out.println(t);
// String[] result = t.split(",");
// for(int i = 0; i < result.length; i++){
// result[i] = StringUtils.substringBefore(result[i], "]");
// result[i] = result[i].substring(1, result[i].length());
// System.out.println(result[i]);
// }
Compare t = new Compare();
t.ConvertStringFile("input2.txt");
}
}