[ 
https://issues.apache.org/jira/browse/CSV-249?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jelmer Kuperus updated CSV-249:
-------------------------------
    Summary: ArrayIndexOutOfBoundsException when trying to read record written 
by CSVPrinter using CSVParser with same format  (was: 
ArrayIndexOutOfBoundsException when trying to read record using CSVParser 
written by CSVPrinter with same format)

> ArrayIndexOutOfBoundsException when trying to read record written by 
> CSVPrinter using CSVParser with same format
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: CSV-249
>                 URL: https://issues.apache.org/jira/browse/CSV-249
>             Project: Commons CSV
>          Issue Type: Bug
>          Components: Parser
>    Affects Versions: 1.5, 1.6, 1.7
>            Reporter: Jelmer Kuperus
>            Priority: Major
>
> The following code will fail with the exception 
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 1 
> out of bounds for length 1
> {noformat}
> 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));
>         });
>     }
> }{noformat}



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to