我正在使用此代码读取 csv 中的一行并获取列名,但问题是我得到了备用的 cloumn 名称。它跳过第一列读取第二列,然后跳过第三列并读取第四列。
BufferedReader br = new BufferedReader(new FileReader(csvFile));
String line = "";
StringTokenizer st = null;
int lineNumber = 0;
int tokenNumber = 0;
//read comma separated file line by line
while ((line = br.readLine()) != null) {
lineNumber++;
//use comma as token separator
st = new StringTokenizer(line, ",");
while (st.hasMoreTokens()) {
//tokenNumber++;
s.add(st.nextToken());
//display csv values
System.out.print(st.nextToken() + " ");
}