CSV文件到java中的数组。有任何想法吗?

时间:2013-10-16 12:22:12

标签: java list names

我正在尝试从CSV文件加载数组。这是代码Find non-duplicate items between two arrays with Java

这会有用吗?

    ReadFile file = new ReadFile( file_name );
    String[ ] aryLines = file.OpenFile( );

1 个答案:

答案 0 :(得分:0)

尝试阅读csv: http://www.mkyong.com/java/how-to-read-and-parse-csv-file-in-java/

然后删除列表A和B中的重复项,您可能想要使用Set(非重复集合)

List<Integer> A = readFromFile("a.csv"); // Arrays.asList(1,2,4)
List<Integer> B = readFromFile("b.csv"); // Arrays.asList(1,2,3)

Set<Integer> set = new TreeSet<Integer>() // will sort for you as well
set.addAll(A)
set.addAll(B)