@@ -244,7 +244,7 @@ public void testExcelFormat1() throws IOException {
244244 {"" },
245245 {"\" hello\" " , " \" world\" " , "abc\n def" , "" }
246246 };
247- CSVParser parser = new CSVParser (new StringReader ( code ) , CSVFormat .EXCEL );
247+ CSVParser parser = new CSVParser (code , CSVFormat .EXCEL );
248248 String [][] tmp = parser .getRecords ();
249249 assertEquals (res .length , tmp .length );
250250 assertTrue (tmp .length > 0 );
@@ -262,7 +262,7 @@ public void testExcelFormat2() throws Exception {
262262 {"" },
263263 {"world" , "" }
264264 };
265- CSVParser parser = new CSVParser (new StringReader ( code ) , CSVFormat .EXCEL );
265+ CSVParser parser = new CSVParser (code , CSVFormat .EXCEL );
266266 String [][] tmp = parser .getRecords ();
267267 assertEquals (res .length , tmp .length );
268268 assertTrue (tmp .length > 0 );
@@ -289,7 +289,7 @@ public void testEndOfFileBehaviourExcel() throws Exception {
289289 };
290290
291291 for (String code : codes ) {
292- CSVParser parser = new CSVParser (new StringReader ( code ) , CSVFormat .EXCEL );
292+ CSVParser parser = new CSVParser (code , CSVFormat .EXCEL );
293293 String [][] tmp = parser .getRecords ();
294294 assertEquals (res .length , tmp .length );
295295 assertTrue (tmp .length > 0 );
@@ -314,9 +314,7 @@ public void testEndOfFileBehaviorCSV() throws Exception {
314314 {"hello" , "" }, // CSV format ignores empty lines
315315 {"world" , "" }
316316 };
317- String code ;
318- for (int codeIndex = 0 ; codeIndex < codes .length ; codeIndex ++) {
319- code = codes [codeIndex ];
317+ for (String code : codes ) {
320318 CSVParser parser = new CSVParser (new StringReader (code ));
321319 String [][] tmp = parser .getRecords ();
322320 assertEquals (res .length , tmp .length );
@@ -339,10 +337,8 @@ public void testEmptyLineBehaviourExcel() throws Exception {
339337 {"" }, // Excel format does not ignore empty lines
340338 {"" }
341339 };
342- String code ;
343- for (int codeIndex = 0 ; codeIndex < codes .length ; codeIndex ++) {
344- code = codes [codeIndex ];
345- CSVParser parser = new CSVParser (new StringReader (code ), CSVFormat .EXCEL );
340+ for (String code : codes ) {
341+ CSVParser parser = new CSVParser (code , CSVFormat .EXCEL );
346342 String [][] tmp = parser .getRecords ();
347343 assertEquals (res .length , tmp .length );
348344 assertTrue (tmp .length > 0 );
@@ -362,9 +358,7 @@ public void testEmptyLineBehaviourCSV() throws Exception {
362358 String [][] res = {
363359 {"hello" , "" } // CSV format ignores empty lines
364360 };
365- String code ;
366- for (int codeIndex = 0 ; codeIndex < codes .length ; codeIndex ++) {
367- code = codes [codeIndex ];
361+ for (String code : codes ) {
368362 CSVParser parser = new CSVParser (new StringReader (code ));
369363 String [][] tmp = parser .getRecords ();
370364 assertEquals (res .length , tmp .length );
@@ -440,7 +434,7 @@ public void testBackslashEscaping() throws IOException {
440434
441435 CSVFormat format = new CSVFormat (',' , '\'' , CSVFormat .DISABLED , '/' , false , false , true , true );
442436
443- CSVParser parser = new CSVParser (new StringReader ( code ) , format );
437+ CSVParser parser = new CSVParser (code , format );
444438 String [][] tmp = parser .getRecords ();
445439 assertTrue (tmp .length > 0 );
446440 for (int i = 0 ; i < res .length ; i ++) {
@@ -468,7 +462,7 @@ public void testBackslashEscaping2() throws IOException {
468462
469463 CSVFormat format = new CSVFormat (',' , CSVFormat .DISABLED , CSVFormat .DISABLED , '/' , false , false , true , true );
470464
471- CSVParser parser = new CSVParser (new StringReader ( code ) , format );
465+ CSVParser parser = new CSVParser (code , format );
472466 String [][] tmp = parser .getRecords ();
473467 assertTrue (tmp .length > 0 );
474468
@@ -495,7 +489,7 @@ public void testDefaultFormat() throws IOException {
495489 CSVFormat format = CSVFormat .DEFAULT ;
496490 assertEquals (CSVFormat .DISABLED , format .getCommentStart ());
497491
498- CSVParser parser = new CSVParser (new StringReader ( code ) , format );
492+ CSVParser parser = new CSVParser (code , format );
499493 String [][] tmp = parser .getRecords ();
500494 assertTrue (tmp .length > 0 );
501495
@@ -510,7 +504,7 @@ public void testDefaultFormat() throws IOException {
510504 };
511505
512506 format = new CSVFormat (',' , '"' , '#' );
513- parser = new CSVParser (new StringReader ( code ) , format );
507+ parser = new CSVParser (code , format );
514508 tmp = parser .getRecords ();
515509
516510 if (!CSVPrinterTest .equals (res_comments , tmp )) {
@@ -521,7 +515,7 @@ public void testDefaultFormat() throws IOException {
521515
522516 public void testUnicodeEscape () throws IOException {
523517 String code = "abc,\\ u0070\\ u0075\\ u0062\\ u006C\\ u0069\\ u0063" ;
524- CSVParser parser = new CSVParser (new StringReader ( code ) , CSVFormat .DEFAULT .withUnicodeEscapesInterpreted (true ));
518+ CSVParser parser = new CSVParser (code , CSVFormat .DEFAULT .withUnicodeEscapesInterpreted (true ));
525519 String [] data = parser .iterator ().next ();
526520 assertEquals (2 , data .length );
527521 assertEquals ("abc" , data [0 ]);
0 commit comments