按姓氏java排序CSV文件

时间:2017-10-03 06:16:30

标签: java csv

我正在尝试使用BufferReader读取Record.java文件,并按姓氏排序列表。当我运行程序时,数组似乎是空的。我究竟做错了什么?我将文件保存在源包中。我需要编写一个方法来按各种参数排序,但我首先要确保正确读取文件并显示。我创建了一个单独的类 private static void readFile() { String fileName; fileName = "IP4_sample_data.csv"; System.out.println("Reading " + fileName); // Create object of the FileReader FileReader reader; try { reader = new FileReader(fileName); // Reader only connects to specified file name BufferedReader bReader = new BufferedReader(reader); String commaString = null; // blank at the beginning // Reads a complete line commaString = bReader.readLine(); // If not last line, add to the record while((commaString = bReader.readLine())!=null) { Record.add(new Record(commaString)); } } catch(Exception e) { System.out.println("Invalid Filename " + e); // readFile(); } } private static void sortRecordsOnLastName() { Collections.sort(records, Record.LastNameComparator()); System.out.println(records); } } ,其中包含正确的算法。这个文件或其他文件中的错误是?

Reading sample_data.csv
Invalid Filename java.lang.UnsupportedOperationException: Not supported yet.
[]
BUILD SUCCESSFUL (total time: 0 seconds)

输出:

map

0 个答案:

没有答案