可以通過流的形式讀取到所有內(nèi)容,之后在轉(zhuǎn)換成元素的形式進(jìn)行實現(xiàn)。舉例:
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();
}
}
}