1
来源:互联网 发布:linux的基本操作 编辑:程序博客网 时间:2024/05/21 20:21
import java.util.ArrayList;import java.util.Collections;import java.util.Comparator;import java.util.HashMap;import java.util.LinkedHashMap;import java.util.List;import java.util.Map;import java.util.Map.Entry;import java.util.Scanner;public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); LinkedHashMap<String, Integer> hm = new LinkedHashMap<String, Integer>(); while(sc.hasNext()){ String path = sc.next(); int line = sc.nextInt(); String[] pathTo = path.split("\\\\"); String fileName = pathTo[pathTo.length-1].trim(); fileName = new String(fileName + " " + line); if(hm.containsKey(fileName)){ int count = hm.get(fileName); count++; hm.put(fileName, count); }else { hm.put(fileName, 1); } } List<Map.Entry<String, Integer>> al = new ArrayList<Map.Entry<String, Integer>>(hm.entrySet()); Collections.sort(al, new Comparator<Map.Entry<String, Integer>>() { @Override public int compare(Entry<String, Integer> arg0, Entry<String, Integer> arg1) { // TODO Auto-generated method stub return arg1.getValue().compareTo(arg0.getValue()); } }); int k=0; //System.out.println(al.size()); for(Map.Entry<String, Integer> mapping : al) { if(k==8) break; String fileName = mapping.getKey(); String[] tmp = fileName.split(" "); String line = tmp[1]; //System.out.println("*"+fileName + " " + tmp[0] + " |" + line); fileName = tmp[0].trim(); if(fileName.length()>16) fileName = fileName.substring(fileName.length()-16, fileName.length()); System.out.println(fileName + " " + line + " " + mapping.getValue()); //System.out.println(mapping.getKey() + " " + mapping.getValue()); k++; } }}
0 0
- 1
- 1
- 1
- 1
- 1
- 1
- 1》
- 1
- 1
- 1
- 1
- (1)
- 1
- 1
- 1
- 1
- 1
- 1
- 内存、时间复杂度、CPU/GPU以及运行时间
- 数据从kafka到hive(1)
- 高斯混合模型
- 哈夫曼树学习笔记 Java实现
- cookie与session的区别
- 1
- opencv在ubuntu12.04下的安装
- Android Ignoring InnerClasses attribute for an anonymous inner class
- Unity手游简单优化
- CentOS 6.4安装配置LAMP服务器(Apache+PHP5+MySQL)
- Android Error:(24, 0) Project with path ':multi-image-selector' could not be found in project ':app'
- 文章标题
- 码云 在线构建apk 在线打包
- Android INSTALL_FAILED_NO_MATCHING_ABIS