I am trying to read CSV file and ignore the comments rows starting with "#". I believe I am setting the right preferences to ignore the comments but still, it is not getting ignored. Can anyone suggest what am i doing wrong.
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();