@@ -212,43 +212,43 @@ private void initFileReader(InputStreamReader sr, String encoding, String demlim
212212 }
213213 }
214214
215- /* RFC4180 specifies that rules for quoted fields. It allows quoted string data to contain newlines data
216- provided the contents otherwise conforms to the rules for escaping quotes. For example, the following is valid:
217- "a","b","c"
218- "aaa ","b <-- newline is retained in data field
219- bb","c"
220- "aa"," bb","cc "
221-
222- We cannot simply use fileReader.readLine() to read these records but instead must continue reading until we reach
223- a newline that is not contained within quotes.
224- */
215+ /*
216+ * RFC4180 specifies that rules for quoted fields. It allows quoted string data to contain newlines data
217+ * provided the contents otherwise conforms to the rules for escaping quotes. For example, the following is valid:
218+ * "a ","b","c"
219+ * "aaa","b <-- newline is retained in data field
220+ * bb","c "
221+ * "aa","bb","cc"
222+ * We cannot simply use fileReader.readLine() to read these records but instead must continue reading until we reach
223+ * a newline that is not contained within quotes.
224+ */
225225 private String readLineEscapeDelimiters () throws SQLServerException {
226226 int quoteCount = 0 ;
227227 StringBuilder sb = new StringBuilder ();
228228 try {
229229 int c ;
230230 while ((c = fileReader .read ()) != -1 ) {
231- if ((c == '\n' || c == '\r' ) && quoteCount % 2 == 0 ) { // newlines only end the record if we are not in quotes
232- fileReader .mark (1 );
233- c = fileReader .read (); // we might have read \r of a \r\n, if so we need to read the \n as well
234- if (c != '\n' ) {
235- fileReader .reset (); // only delimited by \n, unread last char so it goes into the next record
236- }
237- break ;
231+ if ((c == '\n' || c == '\r' ) && quoteCount % 2 == 0 ) { // newlines only end the record if we are not in quotes
232+ fileReader .mark (1 );
233+ c = fileReader .read (); // we might have read \r of a \r\n, if so we need to read the \n as well
234+ if (c != '\n' ) {
235+ fileReader .reset (); // only delimited by \n, unread last char so it goes into the next record
236+ }
237+ break ;
238238 }
239- sb .append ((char )c );
240- if ( c == '"' ) {
239+ sb .append ((char ) c );
240+ if ( c == '"' ) {
241241 quoteCount ++;
242242 }
243243 }
244244 if (c == -1 && quoteCount % 2 != 0 ) { // stream ended, but we are within quotes -- data problem
245- throw new SQLServerException (SQLServerException .getErrString ("R_InvalidCSVQuotes" ),null ,0 , null );
245+ throw new SQLServerException (SQLServerException .getErrString ("R_InvalidCSVQuotes" ), null , 0 , null );
246246 }
247- if (c == -1 ) { // keep semantics of readLine() by returning a null when there is no more data
247+ if (c == -1 ) { // keep semantics of readLine() by returning a null when there is no more data
248248 return null ;
249249 }
250250 } catch (IOException e ) {
251- throw new SQLServerException (e .getMessage (),null ,0 , e );
251+ throw new SQLServerException (e .getMessage (), null , 0 , e );
252252 }
253253 return sb .toString ();
254254 }
0 commit comments