惨叫

今天没学东西,被会长的代码蹂躏,所以就发个他的代码吧

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

public class KaoQing {
    public static void validate(String all,String part)
    {
        String[]alls=all.split("
");
        String[]parts=part.split("
");
        Map<String,Integer> map=new HashMap<String,Integer>();
        for(int i=0;i<alls.length;i++)
            map.put(alls[i], 0);
        for(int i=0;i<parts.length;i++)
            if(map.containsKey(parts[i]))
                map.put(parts[i], 1);
        int count=0;
        for(Entry<String,Integer>e:map.entrySet())
            if(e.getValue()==0)
            {
                System.out.println(e.getKey());
                count++;
            }
        System.out.println("总计"+count);
    }
    public static String readFromTxt(String filename) throws IOException
    {
        BufferedReader br=new BufferedReader(new FileReader(filename));
        String result="";
        String s="";
        while((s=br.readLine())!=null)
            result+=s+"
";
        br.close();
        return result;
    }
    public static void main(String[] args) throws IOException {
        validate(readFromTxt("D:\考勤总名单.txt"),readFromTxt("D:\签到名单.txt"));
    }

}
原文地址:https://www.cnblogs.com/LYY1084702511/p/10836094.html