@CsvEntity(separator = ',') public class Person { @CsvColumn(index = 0) private String name; @CsvColumn(index = 1) private int age; } public List<Person> readCsv(String filePath) throws IOException { CsvParserSettings settings = new CsvParserSettings(); CsvMapper mapper = new CsvMapper(); return mapper.invokeMapper(settings, filePath, Person.class); } public void writeCsv(List<Person> persons, String filePath) throws IOException { CsvWriterSettings settings = new CsvWriterSettings(); CsvMapper mapper = new CsvMapper(); mapper.writeToCsv(settings, filePath, persons, Person.class); }


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