zoukankan      html  css  js  c++  java
  • 文件去重

    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.util.ArrayList;

    import java.util.List;


    public class Test1 {
    public static void main(String[] args)throws IOException{


    String oldFile1="C:\zlb\110.txt";
    String oldFile2="C:\zlb\123.txt";
    String newFile="C:\zlb\222.txt";

    List<String> list1 = new ArrayList<String>();
    BufferedReader in1=new BufferedReader(new InputStreamReader( new FileInputStream(oldFile1), "utf-8"));
    BufferedReader in2=new BufferedReader(new InputStreamReader( new FileInputStream(oldFile2), "utf-8"));
    BufferedWriter ou=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(newFile),"utf-8"));
    String line1;
    String temp;
    String key;

    while( (line1=in1.readLine())!=null){
    list1.add(line1);

    }

    while((temp=in2.readLine())!=null){
    boolean flag=true;
    key=temp.split("=")[0];

    for(int i=0;i<list1.size();i++){
    if(key.equals(list1.get(i))){
    flag=false;
    break;
    }

    }

    if(flag){

    ou.write(temp);
    ou.newLine();

    }

    }

    in2.close();
    ou.close();

    }
    }

  • 相关阅读:
    HDOJ 2102 A计划(bfs)
    HDOJ 1226 超级密码(bfs)
    第一周——Photoshop软件的发展史,并说明其优缺点。
    第一周——Mobile Apps (手机应用)分析
    POJ 3090
    HDU 2824
    UVA 10673
    POJ 1061
    HDU 1358
    POJ 2406
  • 原文地址:https://www.cnblogs.com/bb3q/p/5028905.html
Copyright © 2011-2022 走看看