Java Utililty Methods String Quote

List of utility methods to do String Quote

Description

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

Method

StringquoteStr(Object o)
quote Str
return "'" + o + "'";
StringquoteStrictOccurrences(final String textToMarkup, final String filter)
quote Strict Occurrences
String cur = "";
final String s = textToMarkup.toLowerCase();
for (String part : filter.split(" ")) {
    if (s.contains(part)) {
        cur += "\"" + part + "\" ";
    } else {
        cur += part + " ";
return cur;
StringquoteString(final String input)
Surrounds a string with quotes.
if (input == null)
    throw new IllegalArgumentException("String cannot be null!");
return '"' + input + '"';
StringquoteString(final String str)
Surround the string with single quotes, and backquote any single quotes in the string.
if (str == null) {
    return "null";
String outStr = str.replace("\"", "\\\"");
if (outStr.contains("\n") || outStr.contains(",")) {
    outStr = "\"" + outStr + "\"";
return outStr;
...
StringquoteString(final String string)
Quotes and escapes string for output to CSV format.
if (string == null || string.isEmpty()) {
    return "";
return '"' + string.replace("\"", "\"\"") + '"';
StringquoteString(final String text)
quote String
if (text == null) {
    return null;
final StringBuilder b = new StringBuilder(text.length());
final char[] chars = text.toCharArray();
b.append(QUOTE_CHAR);
for (int i = 0; i < chars.length; i++) {
    final char c = chars[i];
...
StringquoteString(String arg)
quote String
StringBuilder argbuf = new StringBuilder(arg.length() + 2);
return argbuf.append('"').append(arg).append('"').toString();
StringquoteString(String aTarget, String aPrefix, String aSuffix)
quote String
StringBuilder tStringBuilder = new StringBuilder();
tStringBuilder.append(aPrefix);
tStringBuilder.append(aTarget);
tStringBuilder.append(aSuffix);
return tStringBuilder.toString();
StringquoteString(String in)
Simple function to wrap quotes around a valid string.
String ret = null; 
if (in != null) {
    final String QUOTE = "\"";
    ret = QUOTE + in + QUOTE;
return ret;
StringquoteString(String quoted, String quoteFlag)
quote String
assert quoteFlag != null;
if (quoted == null) {
    return "";
} else {
    return quoteFlag + quoted + quoteFlag;