读取csv文件流

public static void readCsvFile(String csvFilePath, String fileEncoder, String separtor) {
InputStreamReader fr = null;
BufferedReader br = null;
try {
fr = new InputStreamReader(new FileInputStream(csvFilePath), fileEncoder);
br = new BufferedReader(fr);
String rec = null;
String[] argsArr = null;
while ((rec = br.readLine()) != null) {
if (rec != null) {
argsArr = rec.split(separtor);
for (int i = 0; i < argsArr.length; i++) {
System.out.print("num " + (i + 1) + ":" + argsArr[i] + "\t");
}
System.out.println();
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fr != null)
fr.close();
} catch (IOException ex) {
ex.printStackTrace();
}
try {
if (br != null)
br.close();
} catch (Exception e2) {
e2.printStackTrace();
}
}


}

你可能感兴趣的:(csv,解析csv文件流)