Java String Double Quote doublequoteEncode(String str)

Here you can find the source of doublequoteEncode(String str)

Description

Doubles every " mark in the string.

License

GNU General Public License

Parameter

Parameter Description
str the string to encode

Return

the string, with each mark doubled

Declaration

public static String doublequoteEncode(String str) 

Method Source Code

//package com.java2s;
/***************************************
 *            ViPER                    *
 *  The Video Processing               *
 *         Evaluation Resource         *
 *                                     *
 *  Distributed under the GPL license  *
 *        Terms available at gnu.org.  *
 *                                     *
 *  Copyright University of Maryland,  *
 *                      College Park.  *
 ***************************************/

public class Main {
    /**// w w w  .ja v a2  s. c  o  m
     * Doubles every " mark in the string.
     * @param str the string to encode
     * @return the string, with each mark doubled
     */
    public static String doublequoteEncode(String str) {
        StringBuffer buf = new StringBuffer(str.length());
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == '"') {
                buf.append("\"\"");
            } else {
                buf.append(str.charAt(i));
            }
        }
        return buf.toString();
    }
}

Related

  1. doubleQuote(String string)
  2. doubleQuote(String value)
  3. doubleQuote(String x)
  4. doubleQuoted(String string)
  5. doubleQuotedString(String str)
  6. doubleQuoteIfNecessary(String string)
  7. doubleQuoteIfNotNull(String str)
  8. doubleQuotes(CharSequence stringToDoubleQuote, boolean escapeDoubleQuote)
  9. doubleQuotes(final String s)