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();

    }
    }

  • 相关阅读:
    tcp/心跳包
    TCP协议中的三次握手和四次挥手(图解)
    http 中get和post
    xmpp总结
    IOS中http请求使用cookie
    sdwebimage总结
    iOS断言
    Object-C自定义对象NSLog输入信息
    NSTimer你真的会用了吗
    ios中block中的探究
  • 原文地址:https://www.cnblogs.com/bb3q/p/5028905.html
Copyright © 2011-2022 走看看