可以通过流的形式读取到所有内容,之后在转换成元素的形式进行实现。举例:
importjava.io.BufferedReader;
importjava.io.FileReader;
importjava.util.*;
publicclassTest{
publicstaticvoidmain(String[]args){
Hashtable<String,String[]>dict=newHashtable<String,String[]>();
try{
BufferedReaderreader=newBufferedReader(newFileReader("test.csv"));
Stringline=null;
while((line=reader.readLine())!=null){
Stringitem[]=line.split(",");
Stringitem2[]=newString[19];
System.arraycopy(item,1,item2,0,19);
dict.put(item[0],item2);
}
Enumeratione2=dict.keys();
while(e2.hasMoreElements()){
Stringkey=(String)e2.nextElement();
System.out.println(key);
String[]dd=(String[])dict.get(key);
for(inti=0;i<dd.length;i++){
System.out.print(dd[i]+"\t");
}
System.out.println();
}
}
catch(Exceptione){
e.printStackTrace();
}
}
}