All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.hackerwin7.jlib.utils.executors.TrainIpUserMapExecutor Maven / Gradle / Ivy

There is a newer version: 0.1.1
Show newest version
package com.github.hackerwin7.jlib.utils.executors;

import com.github.hackerwin7.jlib.utils.drivers.file.FileUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * User: hackerwin7
 * Date: 2015/12/31
 * Time: 2:28 PM
 * Desc:
 */
public class TrainIpUserMapExecutor {
    public static void main(String[] args) throws Exception {
        List ips = FileUtils.file2List("row.list");
        List usrs = FileUtils.file2List("row1.list");
        Map iu = new HashMap<>();
        for(int i = 0; i <= ips.size() - 1; i++) {
            String ip = ips.get(i);
            String user = usrs.get(i);
            if(iu.containsKey(ip)) {
                if(!StringUtils.equalsIgnoreCase(iu.get(ip), user)) {
                    iu.put(ip, iu.get(ip) + "/" + user);
                }
            } else {
                iu.put(ip, user);
            }
        }
        for(Map.Entry entry : iu.entrySet()) {
            System.out.println(entry.getKey() + " " + entry.getValue());
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy