@@ -1371,6 +1371,22 @@ private CSVFormat(final String delimiter, final Character quoteChar, final Quote
13711371 validate ();
13721372 }
13731373
1374+ private void append (final char c , final Appendable appendable ) throws IOException {
1375+ //try {
1376+ appendable .append (c );
1377+ //} catch (final IOException e) {
1378+ // throw new UncheckedIOException(e);
1379+ //}
1380+ }
1381+
1382+ private void append (final CharSequence csq , final Appendable appendable ) throws IOException {
1383+ //try {
1384+ appendable .append (csq );
1385+ //} catch (final IOException e) {
1386+ // throw new UncheckedIOException(e);
1387+ //}
1388+ }
1389+
13741390 /**
13751391 * Creates a new Builder for this instance.
13761392 *
@@ -1606,10 +1622,9 @@ public int hashCode() {
16061622 int result = 1 ;
16071623 result = prime * result + Arrays .hashCode (header );
16081624 result = prime * result + Arrays .hashCode (headerComments );
1609- result = prime * result + Objects .hash (allowDuplicateHeaderNames , allowMissingColumnNames , autoFlush , commentMarker , delimiter , escapeCharacter ,
1625+ return prime * result + Objects .hash (allowDuplicateHeaderNames , allowMissingColumnNames , autoFlush , commentMarker , delimiter , escapeCharacter ,
16101626 ignoreEmptyLines , ignoreHeaderCase , ignoreSurroundingSpaces , nullString , quoteCharacter , quoteMode , quotedNullString , recordSeparator ,
16111627 skipHeaderRecord , trailingDelimiter , trim );
1612- return result ;
16131628 }
16141629
16151630 /**
@@ -1804,7 +1819,7 @@ public CSVPrinter print(final Path out, final Charset charset) throws IOExceptio
18041819 private void print (final Reader reader , final Appendable out , final boolean newRecord ) throws IOException {
18051820 // Reader is never null
18061821 if (!newRecord ) {
1807- out . append (getDelimiterString ());
1822+ append (getDelimiterString (), out );
18081823 }
18091824 if (isQuoteCharacterSet ()) {
18101825 printWithQuotes (reader , out );
@@ -1837,15 +1852,15 @@ public CSVPrinter printer() throws IOException {
18371852 * Outputs the trailing delimiter (if set) followed by the record separator (if set).
18381853 *
18391854 * @param appendable where to write
1840- * @throws IOException If an I/O error occurs
1855+ * @throws IOException If an I/O error occurs.
18411856 * @since 1.4
18421857 */
18431858 public void println (final Appendable appendable ) throws IOException {
18441859 if (getTrailingDelimiter ()) {
1845- appendable . append (getDelimiterString ());
1860+ append (getDelimiterString (), appendable );
18461861 }
18471862 if (recordSeparator != null ) {
1848- appendable . append (recordSeparator );
1863+ append (recordSeparator , appendable );
18491864 }
18501865 }
18511866
@@ -1883,7 +1898,7 @@ private void printWithEscapes(final CharSequence charSeq, final Appendable appen
18831898
18841899 while (pos < end ) {
18851900 char c = charSeq .charAt (pos );
1886- boolean isDelimiterStart = isDelimiter (c , charSeq , pos , delim , delimLength );
1901+ final boolean isDelimiterStart = isDelimiter (c , charSeq , pos , delim , delimLength );
18871902 if (c == CR || c == LF || c == escape || isDelimiterStart ) {
18881903 // write out segment up until this char
18891904 if (pos > start ) {
@@ -1918,7 +1933,7 @@ private void printWithEscapes(final CharSequence charSeq, final Appendable appen
19181933 }
19191934 }
19201935
1921- private void printWithEscapes (final Reader reader , final Appendable out ) throws IOException {
1936+ private void printWithEscapes (final Reader reader , final Appendable appendable ) throws IOException {
19221937 int start = 0 ;
19231938 int pos = 0 ;
19241939
@@ -1932,12 +1947,12 @@ private void printWithEscapes(final Reader reader, final Appendable out) throws
19321947 int c ;
19331948 while (-1 != (c = bufferedReader .read ())) {
19341949 builder .append ((char ) c );
1935- boolean isDelimiterStart = isDelimiter ((char ) c , builder .toString () + new String (bufferedReader .lookAhead (delimLength - 1 )), pos , delim ,
1950+ final boolean isDelimiterStart = isDelimiter ((char ) c , builder .toString () + new String (bufferedReader .lookAhead (delimLength - 1 )), pos , delim ,
19361951 delimLength );
19371952 if (c == CR || c == LF || c == escape || isDelimiterStart ) {
19381953 // write out segment up until this char
19391954 if (pos > start ) {
1940- out . append (builder .substring (start , pos ));
1955+ append (builder .substring (start , pos ), appendable );
19411956 builder .setLength (0 );
19421957 pos = -1 ;
19431958 }
@@ -1947,14 +1962,14 @@ private void printWithEscapes(final Reader reader, final Appendable out) throws
19471962 c = 'r' ;
19481963 }
19491964
1950- out . append (escape );
1951- out . append ((char ) c );
1965+ append (escape , appendable );
1966+ append ((char ) c , appendable );
19521967
19531968 if (isDelimiterStart ) {
19541969 for (int i = 1 ; i < delimLength ; i ++) {
19551970 c = bufferedReader .read ();
1956- out . append (escape );
1957- out . append ((char ) c );
1971+ append (escape , appendable );
1972+ append ((char ) c , appendable );
19581973 }
19591974 }
19601975
@@ -1965,7 +1980,7 @@ private void printWithEscapes(final Reader reader, final Appendable out) throws
19651980
19661981 // write last segment
19671982 if (pos > start ) {
1968- out . append (builder .substring (start , pos ));
1983+ append (builder .substring (start , pos ), appendable );
19691984 }
19701985 }
19711986
@@ -2096,31 +2111,31 @@ private void printWithQuotes(final Reader reader, final Appendable appendable) t
20962111 final char quote = getQuoteCharacter ().charValue ();
20972112 final StringBuilder builder = new StringBuilder (IOUtils .DEFAULT_BUFFER_SIZE );
20982113
2099- appendable . append (quote );
2114+ append (quote , appendable );
21002115
21012116 int c ;
21022117 while (-1 != (c = reader .read ())) {
21032118 builder .append ((char ) c );
21042119 if (c == quote ) {
21052120 // write out segment up until this char
21062121 if (pos > 0 ) {
2107- appendable . append (builder .substring (0 , pos ));
2122+ append (builder .substring (0 , pos ), appendable );
21082123 builder .setLength (0 );
21092124 pos = -1 ;
21102125 }
21112126
2112- appendable . append (quote );
2113- appendable . append ((char ) c );
2127+ append (quote , appendable );
2128+ append ((char ) c , appendable );
21142129 }
21152130 pos ++;
21162131 }
21172132
21182133 // write last segment
21192134 if (pos > 0 ) {
2120- appendable . append (builder .substring (0 , pos ));
2135+ append (builder .substring (0 , pos ), appendable );
21212136 }
21222137
2123- appendable . append (quote );
2138+ append (quote , appendable );
21242139 }
21252140
21262141 @ Override
0 commit comments