Test1.java
1.43 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
package com.yohobuy.ufo;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
/**
* Created by li.ma on 2019/1/14.
*/
public class Test1 {
// 搜索查询的数据,抽取商品编码
public static void main(String[] args) throws IOException {
String fileName = "D:\\tmp\\已存在的货号.txt";
BufferedReader stream = new BufferedReader(new FileReader(fileName));
List<String> idList = new ArrayList<>();
String line;
for (;(line=stream.readLine())!=null ; ) {
idList.add(line.trim());
}
BufferedReader stream1 = new BufferedReader(new FileReader("D:\\tmp\\整体的货号.txt"));
for (;(line=stream1.readLine())!=null ; ) {
if(idList.contains(line)) {
continue;
}
System.out.println(line);
}
}
private static void method1() throws IOException {
String fileName = "C:\\Users\\li.ma\\Desktop\\result.json";
BufferedReader stream = new BufferedReader(new FileReader(fileName));
List<Integer> idList = new ArrayList<>();
while (stream.read()!=-1) {
String line = stream.readLine();
if (null != line && line.contains("\"id\":")) {
int i = line.lastIndexOf("\"id\":");
idList.add(Integer.valueOf(line.substring(i + 5)));
}
}
System.out.println(idList);
}
}