//信1705-2 20173629 何伟豪package 论文查重;import java.io.*;import java.util.*;public class 查重 { public static void main(String[] args){ demo(new File("C:\\Users\\Lenovo\\Desktop\\JAVA\\临时文件\\论文查重\\论文查重\\作文.txt")); } public static void demo(File file){ BufferedReader bfr = null; //定义字符读取(缓冲)流 try{ bfr = new BufferedReader(new FileReader(file)); String value = null; String newValue = ""; while((value = bfr.readLine())!=null){ //开始读取文件中的字符 newValue = newValue+value; //存入newValue变量中 } char[] ch = newValue.toCharArray();//把newValue变成字符数组 TreeMaptm = new TreeMap (Collections.reverseOrder()); for(int x = 0;x > set = tm.entrySet(); Iterator > iter = set.iterator(); while(iter.hasNext()){ Map.Entry map = iter.next(); char k = map.getKey(); int v = map.getValue(); System.out.print(k+"("+v+") "); } } catch(IOException e){ System.out.println("文件读取错误"); } finally{ try{ if(bfr!=null) bfr.close(); } catch(IOException e){ System.out.println("文件关闭错误"); } } }}