Java Utililty Methods String Double Quote

List of utility methods to do String Double Quote

Description

The list of methods to do String Double Quote are organized into topic(s).

Method

StringdoubleQuote(String value)
Double quote the given string; double quotes are escaped.
return quote(value, '"');
StringdoubleQuote(String x)
double Quote
return enclose(x, "\"");
StringdoubleQuoted(String string)
double Quoted
return "\"" + string.replaceAll("\"", "\\\"") + "\"";
StringdoubleQuotedString(String str)
double Quoted String
StringBuilder result = new StringBuilder("\"");
for (int i = 0; i < str.length(); i++) {
    char ch = str.charAt(i);
    if (ch == '\n') {
        result.append("\\n");
        continue;
    if (ch == '\r') {
...
StringdoublequoteEncode(String str)
Doubles every " mark in the string.
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();
StringdoubleQuoteIfNecessary(String string)
Returns a double-quoted String if the said String contains white-space.
return string != null && string.contains(" ") && !string.startsWith("\"") && !string.endsWith("\"")
        ? "\"" + string + "\""
        : string;
StringdoubleQuoteIfNotNull(String str)
double Quote If Not Null
return str = (str != null) ? str = "\"" + str + "\"" : null;
StringdoubleQuotes(CharSequence stringToDoubleQuote, boolean escapeDoubleQuote)
Double quotes the given string (eg.
return "\"" + (escapeDoubleQuote ? escapeDoubleQuote(stringToDoubleQuote) : stringToDoubleQuote) + "\"";
StringdoubleQuotes(final String s)
Returns a string with double quotes at the beginning and at the end of the string.
if (s == null) {
    return null;
return '"' + s + '"';