Description
The following code will fail with the exceptionÂ
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
import org.apache.commons.csv.*; import java.io.StringReader; import java.io.StringWriter; import java.util.List; public class Poc { public static void main(String[] args) throws Exception { CSVFormat csvFormat = CSVFormat.DEFAULT .withEscape('\\'); StringWriter stringWriter = new StringWriter(); CSVPrinter printer = new CSVPrinter(stringWriter, csvFormat); printer.printRecord("foo \\", "bar"); StringReader stringReader = new StringReader(stringWriter.toString()); CSVParser parser = new CSVParser(stringReader, csvFormat); List<CSVRecord> records = parser.getRecords(); records.forEach(record -> { System.out.println(record.get(0)); System.out.println(record.get(1)); }); } }
Attachments
Issue Links
- duplicates
-
CSV-200 CSVFormat cannot read its own output if input contain escape character followed by quote character
- Open