一个日志处理方法 记录一下

package com.sangeng;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class Io {
//    private static String[] words = new String[2000];

    public static void main(String[] args)throws Exception {
            HashMap stringIntegerHashMap = new HashMap<>();;
            BufferedReader br = new BufferedReader(
                    new InputStreamReader(
                            new FileInputStream("src/Demo/log.ini")));
            String linestr;
            while ((linestr = br.readLine()) != null) {
                String[] split = linestr.split("=");
                String[] split1 = split[1].split(",");
                String name = split1[1];
                if (stringIntegerHashMap.putIfAbsent(name, 1)==null){
                    continue;
                };
                int nums = stringIntegerHashMap.get(name);
                System.out.println(name);
                stringIntegerHashMap.put(name,nums+1);
            }
        Iterator> iterator = stringIntegerHashMap.entrySet().iterator();
        while (iterator.hasNext()){
            Map.Entry next = iterator.next();
        }
        br.close();//关闭IO
    }
}

你可能感兴趣的:(杂项记录,java,开发语言)