public void writeNext ( String [ ] nextLine , boolean applyQuotesToAll ) { if ( nextLine == null ) { return ; } StringBuilder sb = new StringBuilder ( nextLine . length * 2 ) ; // This is for the worse case where all elements have to be escaped. for ( int i = 0 ; i < nextLine . length ; i ++ ) { if ( i != 0 ) { sb . append ( separator ) ; } String nextElement = nextLine [ i ] ; if ( nextElement == null ) { continue ; } Boolean stringContainsSpecialCharacters = stringContainsSpecialCharacters ( nextElement ) ; if ( ( applyQuotesToAll || stringContainsSpecialCharacters ) && ( quotechar != NO_QUOTE_CHARACTER ) ) { sb . append ( quotechar ) ; } if ( stringContainsSpecialCharacters ) { sb . append ( processLine ( nextElement ) ) ; } else { sb . append ( nextElement ) ; } if ( ( applyQuotesToAll || stringContainsSpecialCharacters ) && ( quotechar != NO_QUOTE_CHARACTER ) ) { sb . append ( quotechar ) ; } } sb . append ( lineEnd ) ; pw . write ( sb . toString ( ) ) ; }
Writes the next line to the file .