我正在尝试读取CSV文件并忽略以“#”开头的注释行。我相信我正在设置正确的偏好来忽略评论,但仍然没有被忽略。任何人都可以建议我做错了什么。
if (file.exists()) {
InputStream inputStream =
new ByteArrayInputStream(
FileUtils
.readFileToByteArray(
file));
InputStreamReader
inputStreamReaderAsync =
new InputStreamReader(
inputStream,
"UTF-8");
beanReader =
new CsvBeanReader(
inputStreamReaderAsync,
BulkDownloadServiceImpl.STANDARD_SKIP_COMMENTS);
// the header elements are used to map the values to the bean (names must match)
header =
beanReader.getHeader(
true);
inputStream.close();
isError = false;
}
private static final CsvPreference STANDARD_SKIP_COMMENTS =
new CsvPreference.Builder(CsvPreference.STANDARD_PREFERENCE).skipComments(
new CommentStartsWith("#")).build();