@@ -124,20 +124,17 @@ public void printlnComment(String comment) throws IOException {
124124
125125 public void print (char [] value , int offset , int len , boolean checkForEscape ) throws IOException {
126126 if (!checkForEscape ) {
127- if (newLine ) {
128- newLine = false ;
129- } else {
130- out .write (this .strategy .getDelimiter ());
131- }
127+ printSep ();
132128 out .write (value , offset , len );
133129 return ;
134130 }
135131
136- if (strategy .getEncapsulator () != ( char )- 2 ) {
132+ if (strategy .getEncapsulator () != CSVStrategy . ENCAPSULATOR_DISABLED ) {
137133 printAndEncapsulate (value , offset , len );
138- } else if (strategy .getEscape () != ( char )- 2 ) {
134+ } else if (strategy .getEscape () != CSVStrategy . ESCAPE_DISABLED ) {
139135 printAndEscape (value , offset , len );
140136 } else {
137+ printSep ();
141138 out .write (value , offset , len );
142139 }
143140 }
@@ -155,11 +152,11 @@ void printAndEscape(char[] value, int offset, int len) throws IOException {
155152 int pos = offset ;
156153 int end = offset + len ;
157154
155+ printSep ();
156+
158157 char delim = this .strategy .getDelimiter ();
159158 char escape = this .strategy .getEscape ();
160159
161- printSep ();
162-
163160 while (pos < end ) {
164161 char c = value [pos ];
165162 if (c == '\r' || c =='\n' || c ==delim || c ==escape ) {
@@ -194,11 +191,11 @@ void printAndEncapsulate(char[] value, int offset, int len) throws IOException {
194191 int pos = offset ;
195192 int end = offset + len ;
196193
194+ printSep ();
195+
197196 char delim = this .strategy .getDelimiter ();
198197 char encapsulator = this .strategy .getEncapsulator ();
199198
200- printSep ();
201-
202199 if (len <= 0 ) {
203200 // always quote an empty token that is the first
204201 // on the line, as it may be the only thing on the
@@ -285,6 +282,7 @@ void printAndEncapsulate(char[] value, int offset, int len) throws IOException {
285282 public void print (String value , boolean checkForEscape ) throws IOException {
286283 if (!checkForEscape ) {
287284 // write directly from string
285+ printSep ();
288286 out .write (value );
289287 return ;
290288 }
0 commit comments