Test1.java 1.43 KB
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);
    }
}