java如何跳过记录中的注释
我正在使用Apache Commons CSV 1.9.0库来解析CSV文件,问题是我无法设置注释标记“#”来填充记录中的注释字段,以便在循环文件时跳过它们。 这是我正在使用的代码:
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVRecord;
Reader reader = Files.newBufferedReader((Paths.get(filename)), StandardCharsets.UTF_16LE);
CSVFormat csvFormat = CSVFormat.DEFAULT;
csvFormat.builder().setCommentMarker('#');
Iterable<CSVRecord> records = csvFormat.parse(reader);
char marker = csvFormat.getCommentMarker(); // marker is for test and it is empty.
for (CSVRecord record : records)
{
if (record.isSet(SHEET_COLUMN_1))
{
// TODO
}
}
你能帮我吗
亲切的问候, 马恩
共 (0) 个答案