CSVParser implements Iterable<CSVRecord>, Closeable { public List<CSVRecord> getRecords() throws IOException { final List<CSVRecord> records = new ArrayList<CSVRecord>(); CSVRecord rec; while ((rec = this.nextRecord()) != null) { records.add(rec); } return records; } CSVParser(final Reader reader, final CSVFormat format); static CSVParser parse(File file, final CSVFormat format); static CSVParser parse(String string, final CSVFormat format); static CSVParser parse(URL url, Charset charset, final CSVFormat format); void close(); long getCurrentLineNumber(); Map<String, Integer> getHeaderMap(); long getRecordNumber(); List<CSVRecord> getRecords(); boolean isClosed(); Iterator<CSVRecord> iterator();  }
@Test public void testGetRecords() throws IOException { final CSVParser parser = CSVParser.parse(CSVINPUT, CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true)); final List<CSVRecord> records = parser.getRecords(); assertEquals(RESULT.length, records.size()); assertTrue(records.size() > 0); for (int i = 0; i < RESULT.length; i++) { assertArrayEquals(RESULT[i], records.get(i).values()); } }