diff --git a/src/site/xdoc/index.xml b/src/site/xdoc/index.xml index 95df90e9..d4909d9d 100644 --- a/src/site/xdoc/index.xml +++ b/src/site/xdoc/index.xml @@ -32,7 +32,28 @@ for (CSVRecord record : records) { String firstName = record.get("First Name"); }

Other formats are available, please consult the Javadoc for CSVFormat and - CSVParser.

+ CSVParser. +

+ +
+

+ To handle files that start with a Byte Order Mark (BOM) like some Excel CSV files, you need an extra step to deal with these optional bytes. + You can use the + BOMInputStream + class from Apache Commons IO for example: +

+ final URL url = ...; +final Reader reader = new InputStreamReader(new BOMInputStream(url.openStream()), "UTF-8"); +final CSVParser parser = new CSVParser(reader, CSVFormat.EXCEL.withHeader()); +try { + for (final CSVRecord record : parser) { + final String string = record.get("SomeColumn"); + ... + } +} finally { + parser.close(); + reader.close(); +}