//1.遍历数据 BufferedReader bis = new BufferedReader(new FileReader("csb.txt")); String line; TreeMap <Integer,String> tm= new TreeMap<>(); while ((line = bis.readLine()) != null) { String[] arr = line.split("\\."); //0:x序号 //1:内容 //添加到集合中 tm.put(Integer.parseInt(arr[0]),line); } bis.close(); //2.进行排序 BufferedWriter bw = new BufferedWriter(new FileWriter("bbb.txt")); //遍历 Set<Map.Entry<Integer, String>> entries = tm.entrySet(); for (Map.Entry<Integer, String> entry : entries) { //获得值 String value = entry.getValue(); bw.write(value); bw.newLine(); } bw.close();
出师表排序2
最新推荐文章于 2024-08-18 22:05:18 发布