Read/Write CSV File With OpenCSV: Đọc/Ghi CSV Fille với OpenCSV
Nếu bạn chưa biết tải bộ thư viện này ở đâu thì có thể click vào đây!
Còn nếu bạn chưa biết làm sao để thêm bộ thư viện này vào project của mình thì có thể vào đây!
Chúng ta bắt đầu với một ví dụ đọc file csv như sau:
public class TestProgram {
public static void main(String[] args){
CSVReader reader = new CSVReader(new FileReader("yourfile.csv"));
String [] nextLine;
while ((nextLine = reader.readNext()) != null) {
// nextLine[] is an array of values from the line
System.out.println(nextLine[0] + nextLine[1] + "etc...");
}
}
}
0 comments:
Post a Comment