@@ -97,7 +97,7 @@ public void println(String... values) throws IOException {
9797 * @param comment the comment to output
9898 */
9999 public void printComment (String comment ) throws IOException {
100- if (this . format .isCommentingDisabled ()) {
100+ if (format .isCommentingDisabled ()) {
101101 return ;
102102 }
103103 if (!newLine ) {
@@ -127,13 +127,7 @@ public void printComment(String comment) throws IOException {
127127 }
128128
129129
130- private void print (char [] value , int offset , int len , boolean checkForEscape ) throws IOException {
131- if (!checkForEscape ) {
132- printSep ();
133- out .write (value , offset , len );
134- return ;
135- }
136-
130+ private void print (char [] value , int offset , int len ) throws IOException {
137131 if (format .isEncapsulating ()) {
138132 printAndEncapsulate (value , offset , len );
139133 } else if (format .isEscaping ()) {
@@ -148,7 +142,7 @@ void printSep() throws IOException {
148142 if (newLine ) {
149143 newLine = false ;
150144 } else {
151- out .write (this . format .getDelimiter ());
145+ out .write (format .getDelimiter ());
152146 }
153147 }
154148
@@ -159,8 +153,8 @@ void printAndEscape(char[] value, int offset, int len) throws IOException {
159153
160154 printSep ();
161155
162- char delim = this . format .getDelimiter ();
163- char escape = this . format .getEscape ();
156+ char delim = format .getDelimiter ();
157+ char escape = format .getEscape ();
164158
165159 while (pos < end ) {
166160 char c = value [pos ];
@@ -201,8 +195,8 @@ void printAndEncapsulate(char[] value, int offset, int len) throws IOException {
201195
202196 printSep ();
203197
204- char delim = this . format .getDelimiter ();
205- char encapsulator = this . format .getEncapsulator ();
198+ char delim = format .getDelimiter ();
199+ char encapsulator = format .getEncapsulator ();
206200
207201 if (len <= 0 ) {
208202 // always quote an empty token that is the first
@@ -288,6 +282,11 @@ void printAndEncapsulate(char[] value, int offset, int len) throws IOException {
288282 * @param value value to be outputted.
289283 */
290284 public void print (String value , boolean checkForEscape ) throws IOException {
285+ if (value == null ) {
286+ // null values are considered empty
287+ value = "" ;
288+ }
289+
291290 if (!checkForEscape ) {
292291 // write directly from string
293292 printSep ();
@@ -300,7 +299,7 @@ public void print(String value, boolean checkForEscape) throws IOException {
300299 }
301300
302301 value .getChars (0 , value .length (), buf , 0 );
303- print (buf , 0 , value .length (), checkForEscape );
302+ print (buf , 0 , value .length ());
304303 }
305304
306305 /**
0 commit comments