Java读取csv文件乱码

后来改为这样就可以了:

public static List read(String path){
List fishTackleTypes=new ArrayList();
try{
File file=new File(path);
DataInputStream in=new DataInputStream(new FileInputStream(file));
BufferedReader br=new BufferedReader(new InputStreamReader(in,"utf-8"));
//读取直到最后一行
String line="";
while((line=br.readLine())!=null){
StringTokenizer st=new StringTokenizer(line,",");
while(st.hasMoreTokens()){
FishTackleType fishTackleType=new FishTackleType();
fishTackleType.setTypeId(Integer.parseInt(st.nextToken()));
fishTackleType.setName(st.nextToken());
fishTackleTypes.add(fishTackleType);
}
}
br.close();
}catch(Exception e){
e.printStackTrace();
}
return fishTackleTypes;
}

你可能感兴趣的:(CSV)