----------------------------------------------
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import com.csvreader.CsvReader;
import com.csvreader.CsvWriter;
public class readeCsv{
public static void main(String args[]){
try {
ArrayList
String csvFilePath = "c:/test.csv"; // 要讀取的檔案路徑
CsvReader reader = new CsvReader(csvFilePath,',',Charset.forName("SJIS")); //
//reader.readHeaders(); //
while(reader.readRecord()){ //
csvList.add(reader.getValues());
}
reader.close();
for(int row=0;row < csvList.size();row++){ // row 行
for (int column=0;column < csvList.get(row).length;column++) {
String cell = csvList.get(row)[column]; // column 列
//System.out.println(csvList.get(row).length);
System.out.print(cell);
System.out.print("\t");
}
System.out.print("\n");
}
}catch(Exception ex){
System.out.println(ex);
}
}
}
沒有留言:
張貼留言