@@ -71,7 +71,7 @@ public class CSVParserTest {
7171
7272 @ Test
7373 public void testGetLine () throws IOException {
74- final CSVParser parser = new CSVParser (new StringReader (CSVINPUT ), CSVFormat .defaults ().withIgnoreSurroundingSpaces (true ).build ());
74+ final CSVParser parser = new CSVParser (new StringReader (CSVINPUT ), CSVFormat .newBuilder ().withIgnoreSurroundingSpaces (true ).build ());
7575 for (final String [] re : RESULT ) {
7676 assertArrayEquals (re , parser .nextRecord ().values ());
7777 }
@@ -81,7 +81,7 @@ public void testGetLine() throws IOException {
8181
8282 @ Test
8383 public void testGetRecords () throws IOException {
84- final CSVParser parser = new CSVParser (new StringReader (CSVINPUT ), CSVFormat .defaults ().withIgnoreSurroundingSpaces (true ).build ());
84+ final CSVParser parser = new CSVParser (new StringReader (CSVINPUT ), CSVFormat .newBuilder ().withIgnoreSurroundingSpaces (true ).build ());
8585 final List <CSVRecord > records = parser .getRecords ();
8686 assertEquals (RESULT .length , records .size ());
8787 assertTrue (records .size () > 0 );
@@ -312,7 +312,7 @@ public void testBackslashEscaping() throws IOException {
312312 };
313313
314314
315- final CSVFormat format = CSVFormat .newFormat (',' ).withQuoteChar ('\'' ).withEscape ('/' )
315+ final CSVFormat format = CSVFormat .newBuilder (',' ).withQuoteChar ('\'' ).withEscape ('/' )
316316 .withIgnoreEmptyLines (true ).withRecordSeparator (CRLF ).build ();
317317
318318 final CSVParser parser = new CSVParser (code , format );
@@ -342,7 +342,7 @@ public void testBackslashEscaping2() throws IOException {
342342 };
343343
344344
345- final CSVFormat format = CSVFormat .newFormat (',' ).withEscape ('/' )
345+ final CSVFormat format = CSVFormat .newBuilder (',' ).withEscape ('/' )
346346 .withIgnoreEmptyLines (true ).withRecordSeparator (CRLF ).build ();
347347
348348 final CSVParser parser = new CSVParser (code , format );
@@ -381,7 +381,7 @@ public void testDefaultFormat() throws IOException {
381381 {"\n " , " " , "#" },
382382 };
383383
384- format = CSVFormat .defaults ().withCommentStart ('#' ).build ();
384+ format = CSVFormat .newBuilder ().withCommentStart ('#' ).build ();
385385 parser = new CSVParser (code , format );
386386 records = parser .getRecords ();
387387
@@ -481,7 +481,7 @@ public void testIterator() throws Exception {
481481 public void testHeader () throws Exception {
482482 final Reader in = new StringReader ("a,b,c\n 1,2,3\n x,y,z" );
483483
484- final Iterator <CSVRecord > records = CSVFormat .defaults ().withHeader ().build ().parse (in ).iterator ();
484+ final Iterator <CSVRecord > records = CSVFormat .newBuilder ().withHeader ().build ().parse (in ).iterator ();
485485
486486 for (int i = 0 ; i < 2 ; i ++) {
487487 assertTrue (records .hasNext ());
@@ -498,7 +498,7 @@ public void testHeader() throws Exception {
498498 public void testHeaderComment () throws Exception {
499499 final Reader in = new StringReader ("# comment\n a,b,c\n 1,2,3\n x,y,z" );
500500
501- final Iterator <CSVRecord > records = CSVFormat .defaults ().withCommentStart ('#' ).withHeader ().build ().parse (in ).iterator ();
501+ final Iterator <CSVRecord > records = CSVFormat .newBuilder ().withCommentStart ('#' ).withHeader ().build ().parse (in ).iterator ();
502502
503503 for (int i = 0 ; i < 2 ; i ++) {
504504 assertTrue (records .hasNext ());
@@ -515,7 +515,7 @@ public void testHeaderComment() throws Exception {
515515 public void testProvidedHeader () throws Exception {
516516 final Reader in = new StringReader ("a,b,c\n 1,2,3\n x,y,z" );
517517
518- final Iterator <CSVRecord > records = CSVFormat .defaults ().withHeader ("A" , "B" , "C" ).build ().parse (in ).iterator ();
518+ final Iterator <CSVRecord > records = CSVFormat .newBuilder ().withHeader ("A" , "B" , "C" ).build ().parse (in ).iterator ();
519519
520520 for (int i = 0 ; i < 3 ; i ++) {
521521 assertTrue (records .hasNext ());
@@ -536,7 +536,7 @@ public void testProvidedHeader() throws Exception {
536536 public void testMappedButNotSetAsOutlook2007ContactExport () throws Exception {
537537 final Reader in = new StringReader ("a,b,c\n 1,2\n x,y,z" );
538538
539- final Iterator <CSVRecord > records = CSVFormat .defaults ().withHeader ("A" , "B" , "C" ).build ().parse (in ).iterator ();
539+ final Iterator <CSVRecord > records = CSVFormat .newBuilder ().withHeader ("A" , "B" , "C" ).build ().parse (in ).iterator ();
540540
541541 // header record
542542 assertTrue (records .hasNext ());
@@ -578,7 +578,7 @@ record = records.next();
578578 }
579579
580580 public void testGetHeaderMap () throws Exception {
581- final CSVParser parser = new CSVParser ("a,b,c\n 1,2,3\n x,y,z" , CSVFormat .defaults ().withHeader ("A" , "B" , "C" ).build ());
581+ final CSVParser parser = new CSVParser ("a,b,c\n 1,2,3\n x,y,z" , CSVFormat .newBuilder ().withHeader ("A" , "B" , "C" ).build ());
582582 final Map <String , Integer > headerMap = parser .getHeaderMap ();
583583 final Iterator <String > columnNames = headerMap .keySet ().iterator ();
584584 // Headers are iterated in column order.
@@ -622,7 +622,7 @@ public void testGetRecordNumberWithLF() throws Exception {
622622 @ Test
623623 public void testGetRecordWithMultiiLineValues () throws Exception {
624624 final CSVParser parser = new CSVParser ("\" a\r \n 1\" ,\" a\r \n 2\" " + CRLF + "\" b\r \n 1\" ,\" b\r \n 2\" " + CRLF + "\" c\r \n 1\" ,\" c\r \n 2\" " ,
625- CSVFormat .defaults ().withRecordSeparator (CRLF ).build ());
625+ CSVFormat .newBuilder ().withRecordSeparator (CRLF ).build ());
626626 CSVRecord record ;
627627 assertEquals (0 , parser .getRecordNumber ());
628628 assertEquals (0 , parser .getLineNumber ());
@@ -654,7 +654,7 @@ public void testGetRecordNumberWithCR() throws Exception {
654654 }
655655
656656 private void validateRecordNumbers (String lineSeparator ) throws IOException {
657- final CSVParser parser = new CSVParser ("a" + lineSeparator + "b" + lineSeparator + "c" , CSVFormat .defaults ().withRecordSeparator (lineSeparator ).build ());
657+ final CSVParser parser = new CSVParser ("a" + lineSeparator + "b" + lineSeparator + "c" , CSVFormat .newBuilder ().withRecordSeparator (lineSeparator ).build ());
658658 CSVRecord record ;
659659 assertEquals (0 , parser .getRecordNumber ());
660660 assertNotNull (record = parser .nextRecord ());
@@ -671,7 +671,7 @@ private void validateRecordNumbers(String lineSeparator) throws IOException {
671671 }
672672
673673 private void validateLineNumbers (String lineSeparator ) throws IOException {
674- final CSVParser parser = new CSVParser ("a" + lineSeparator + "b" + lineSeparator + "c" , CSVFormat .defaults ().withRecordSeparator (lineSeparator ).build ());
674+ final CSVParser parser = new CSVParser ("a" + lineSeparator + "b" + lineSeparator + "c" , CSVFormat .newBuilder ().withRecordSeparator (lineSeparator ).build ());
675675 assertEquals (0 , parser .getLineNumber ());
676676 assertNotNull (parser .nextRecord ());
677677 assertEquals (1 , parser .getLineNumber ());
0 commit comments