@Test public void testRecordsFromFileWithStrictQuotes() throws IOException { FileReader fr = new FileReader("src/test/resources/basic.csv"); CsvParser p = new CsvParserBuilder().strictQuotes(true).build(); csvr = new CsvReaderBuilder(fr).skipLines(1).csvParser(p).build(); String[] toks = csvr.readNext(); assertEquals(5, toks.length); assertEquals("", toks[0]); assertEquals("", toks[1]); assertEquals("Stan Musial", toks[2]); assertEquals("Mike \\\"The Situation\\\"", toks[3]); assertEquals("I\\nlike\\nIke", toks[4]); toks = csvr.readNext(); assertEquals(5, toks.length); assertEquals("", toks[0]); assertEquals("", toks[1]); assertEquals("", toks[2]); assertEquals("", toks[3]); assertEquals("", toks[4]); toks = csvr.readNext(); assertEquals(2, toks.length); assertEquals("abcefg", toks[0]); assertEquals("Stan Musial", toks[1]); toks = csvr.readNext(); assertEquals(1, toks.length); assertEquals("", toks[0]); toks = csvr.readNext(); assertEquals(6, toks.length); assertEquals("", toks[0]); assertEquals("", toks[1]); assertEquals("", toks[2]); assertEquals("", toks[3]); assertEquals("\\t", toks[4]); assertEquals("", toks[5]); toks = csvr.readNext(); assertNull(toks); }
public String[] readNext() throws IOException, CsvRecordException { try { while (skipLines > 0) { if (parser.parseNext(br) == null) { skipLines = 0; } else { recordNumber++; skipLines--; } } List<String> next = parser.parseNext(br); if (next == null) { return null; } recordNumber++; return next.toArray(new String[next.size()]); } catch (CsvRecordException re) { CsvRecordException nre = new CsvRecordException(re.getMessage() + ": " + recordNumber + "."); nre.setStackTrace(re.getStackTrace()); throw nre; } }
CsvReader implements Closeable, Iterable<String[]> { public String[] readNext() throws IOException, CsvRecordException { try { while (skipLines > 0) { if (parser.parseNext(br) == null) { skipLines = 0; } else { recordNumber++; skipLines--; } } List<String> next = parser.parseNext(br); if (next == null) { return null; } recordNumber++; return next.toArray(new String[next.size()]); } catch (CsvRecordException re) { CsvRecordException nre = new CsvRecordException(re.getMessage() + ": " + recordNumber + "."); nre.setStackTrace(re.getStackTrace()); throw nre; } } }
CsvReader implements Closeable, Iterable<String[]> { public String[] readNext() throws IOException, CsvRecordException { try { while (skipLines > 0) { if (parser.parseNext(br) == null) { skipLines = 0; } else { recordNumber++; skipLines--; } } List<String> next = parser.parseNext(br); if (next == null) { return null; } recordNumber++; return next.toArray(new String[next.size()]); } catch (CsvRecordException re) { CsvRecordException nre = new CsvRecordException(re.getMessage() + ": " + recordNumber + "."); nre.setStackTrace(re.getStackTrace()); throw nre; } } CsvReader(Reader reader);  CsvReader(Reader reader, int line);  CsvReader(Reader reader, CsvParser csvParser);  CsvReader(Reader reader, int line, CsvParser csvParser); }
CsvReader implements Closeable, Iterable<String[]> { public String[] readNext() throws IOException, CsvRecordException { try { while (skipLines > 0) { if (parser.parseNext(br) == null) { skipLines = 0; } else { recordNumber++; skipLines--; } } List<String> next = parser.parseNext(br); if (next == null) { return null; } recordNumber++; return next.toArray(new String[next.size()]); } catch (CsvRecordException re) { CsvRecordException nre = new CsvRecordException(re.getMessage() + ": " + recordNumber + "."); nre.setStackTrace(re.getStackTrace()); throw nre; } } CsvReader(Reader reader);  CsvReader(Reader reader, int line);  CsvReader(Reader reader, CsvParser csvParser);  CsvReader(Reader reader, int line, CsvParser csvParser); List<String[]> readAll(); String[] readNext(); @Override void close(); @Override Iterator<String[]> iterator(); }
CsvReader implements Closeable, Iterable<String[]> { public String[] readNext() throws IOException, CsvRecordException { try { while (skipLines > 0) { if (parser.parseNext(br) == null) { skipLines = 0; } else { recordNumber++; skipLines--; } } List<String> next = parser.parseNext(br); if (next == null) { return null; } recordNumber++; return next.toArray(new String[next.size()]); } catch (CsvRecordException re) { CsvRecordException nre = new CsvRecordException(re.getMessage() + ": " + recordNumber + "."); nre.setStackTrace(re.getStackTrace()); throw nre; } } CsvReader(Reader reader);  CsvReader(Reader reader, int line);  CsvReader(Reader reader, CsvParser csvParser);  CsvReader(Reader reader, int line, CsvParser csvParser); List<String[]> readAll(); String[] readNext(); @Override void close(); @Override Iterator<String[]> iterator(); static final int DEFAULT_SKIP_LINES; }