@Override
  /**
   * copied from org.supercsv.io.AbstractCsvWriter
   *
   * @see org.supercsv.io.AbstractCsvWriter
   */
  protected String escapeString(String csvElement) {
    String escaped = super.escapeString(csvElement);

    if (!StringUtils.startsWith(escaped, String.valueOf((char) preference.getQuoteChar()))) {
      return (char) preference.getQuoteChar() + escaped + (char) preference.getQuoteChar();
    }

    return escaped;
  }
예제 #2
0
 /**
  * Constructs a new <tt>Tokenizer</tt>, which reads the CSV file, line by line.
  *
  * @param reader the reader
  * @param preferences the CSV preferences
  * @throws NullPointerException if reader or preferences is null
  */
 public Tokenizer(
     final Reader reader,
     final CsvPreference preferences,
     boolean strictquotes,
     char escapechar,
     long columnsizelimit,
     long skipNum) {
   super(reader, preferences);
   this.quoteChar = preferences.getQuoteChar();
   this.delimeterChar = preferences.getDelimiterChar();
   this.surroundingSpacesNeedQuotes = preferences.isSurroundingSpacesNeedQuotes();
   this.commentMatcher = preferences.getCommentMatcher();
   this.strictQuotes = strictquotes;
   this.escapeChar = escapechar;
   this.columnSizeLimit = columnsizelimit;
   this.skip = skipNum;
 }