File tree Expand file tree Collapse file tree
src/test/java/org/apache/commons/csv/issues Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626import java .util .ArrayList ;
2727import java .util .Iterator ;
2828import java .util .List ;
29+ import java .util .stream .Collectors ;
2930
3031import org .apache .commons .csv .CSVFormat ;
3132import org .apache .commons .csv .CSVParser ;
5556// 3 a b,c,d "quoted" e
5657//
5758public class JiraCsv290Test {
59+
5860 private void testHelper (final String filename , final CSVFormat format ) throws Exception {
59- final List <List <String >> content = new ArrayList <>();
60- try (CSVParser csvParser = CSVParser .parse (new InputStreamReader (
61- this .getClass ().getResourceAsStream ("/org/apache/commons/csv/CSV-290/" + filename )), format )) {
62- for (CSVRecord csvRecord : csvParser ) {
63- final List <String > row = new ArrayList <>();
64- content .add (row );
65- for (int i = 0 ; i < csvRecord .size (); i ++) {
66- row .add (csvRecord .get (i ));
67- }
68- }
61+ List <List <String >> content = new ArrayList <>();
62+ try (CSVParser csvParser = CSVParser .parse (new InputStreamReader (this .getClass ().getResourceAsStream ("/org/apache/commons/csv/CSV-290/" + filename )),
63+ format )) {
64+ content = csvParser .stream ().collect (Collectors .mapping (CSVRecord ::toList , Collectors .toList ()));
6965 }
7066
7167 assertEquals (3 , content .size ());
You can’t perform that action at this time.
0 commit comments