/** * A streaming version of the quoting algorithm for more performance. Encodes the string, so that the string can * safely be used in CSV files. If the string does not need quoting, the original string is returned unchanged. * * @param original the unquoted string. * @param writer the writer. * @throws IOException if an IO error occured. */ public void doQuoting( final String original, final Writer writer ) throws IOException { if ( isQuotingNeeded( original ) ) { writer.write( quate ); applyQuote( writer, original ); writer.write( quate ); } else { writer.write( original ); } }
/** * Encodes the string, so that the string can safely be used in CSV files. If the string does not need quoting, the * original string is returned unchanged. * * @param original the unquoted string. * @return The quoted string */ public String doQuoting( final String original ) { if ( forceQuote || isQuotingNeeded( original ) ) { final StringBuffer retval = new StringBuffer( original.length() + 5 ); // a safe guess most of the time. retval.append( quate ); applyQuote( retval, original ); retval.append( quate ); return retval.toString(); } else { return original; } }
/** * A streaming version of the quoting algorithm for more performance. Encodes the string, so that the string can * safely be used in CSV files. If the string does not need quoting, the original string is returned unchanged. * * @param original the unquoted string. * @param writer the writer. * @throws IOException if an IO error occured. */ public void doQuoting (final String original, final Writer writer) throws IOException { if (isQuotingNeeded(original)) { writer.write(quate); applyQuote(writer, original); writer.write(quate); } else { writer.write(original); } }
/** * Encodes the string, so that the string can safely be used in CSV files. If the string * does not need quoting, the original string is returned unchanged. * * @param original the unquoted string. * @return The quoted string */ public String doQuoting (final String original) { if (isQuotingNeeded(original)) { final StringBuffer retval = new StringBuffer(original.length() + 5); // a safe guess most of the time. retval.append(quate); applyQuote(retval, original); retval.append(quate); return retval.toString(); } else { return original; } }