import org.apache.commons.csv.*; public class CSVReaderExample { public static void main(String[] args) { try (CSVParser parser = CSVParser.parse(new File("data.csv"), Charset.defaultCharset(), CSVFormat.DEFAULT)) { for (CSVRecord record : parser) { String name = record.get(0); int age = Integer.parseInt(record.get(1)); System.out.println("Name: " + name + ", Age: " + age); } } catch (IOException e) { e.printStackTrace(); } } }


上一篇:
下一篇:
切换中文