Look at the CSVParserTest if you have downloaded the code.
Your request made me realize we commented all this very well in the javadocs (Look at the javadocs for CSVParserBuilder or RFC4180ParserBuilder) but the example we have on the sourceforge page (http://opencsv.sourceforge.net/) could use some updating. Will try and look into tat in the next release.
but here is one of the unit tests we have that will give you an example.
/** * Test issue 2263439 where an escaped quote was causing the parse to fail. * Special thanks to Chris Morris for fixing this (id 1979054) * * @throws IOException But not really */
@TestpublicvoidtestIssue2263439()throwsIOException {
csvParser=newCSVParserBuilder()
.withSeparator(',')
.withQuoteChar('\'')
.build();String[] nextLine=csvParser.parseLine("865,0,'AmeriKKKa\\'s_Most_Wanted','',294,0,0,0.734338696798625,'20081002052147',242429208,18448");assertEquals(11, nextLine.length);assertEquals("865", nextLine[0]);assertEquals("0", nextLine[1]);assertEquals("AmeriKKKa's_Most_Wanted", nextLine[2]);assertEquals("", nextLine[3]);assertEquals("18448", nextLine[10]);
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
withSeparator() in whatever builder you are using directly (CsvToBeanBuilder, most likely).
Look at the CSVParserTest if you have downloaded the code.
Your request made me realize we commented all this very well in the javadocs (Look at the javadocs for CSVParserBuilder or RFC4180ParserBuilder) but the example we have on the sourceforge page (http://opencsv.sourceforge.net/) could use some updating. Will try and look into tat in the next release.
but here is one of the unit tests we have that will give you an example.