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

Stringquote(String str)
Quotes a String.
StringBuffer sb = new StringBuffer();
sb.append("\"").append(str).append("\"");
return sb.toString();
Stringquote(String str)
quote
if (str == null)
    return str;
if (str.length() < 2 || !str.startsWith("\"") || !str.endsWith("\""))
    str = "\"" + str + "\"";
return str;
Stringquote(String str)
Returns a quoted string, surrounded with double quote
return surround(str, "\"");
Stringquote(String str)
Quote and escape a string for use in shell commands.
return "\"" + str.replaceAll("\\\\", "\\\\\\\\").replaceAll("\"", "\\\\\"") + "\"";
Stringquote(String str, char c)
Inserts a given character at the beginning and at the end of the specified string.
assert (str != null);
StringBuffer buffer = new StringBuffer(str.length() + 2);
buffer.append(c);
buffer.append(str);
buffer.append(c);
return buffer.toString();
Stringquote(String str, String quoteChar)
Quote the given String with passed quoteChar.
return (str != null ? quoteChar + str + quoteChar : null);
StringBufferquote(String str, StringBuffer out)
quote
if (out == null) {
    out = new StringBuffer();
out.append('"');
int len = str.length();
for (int i = 0; i < len; i++) {
    char c = str.charAt(i);
    switch (c) {
...
Stringquote(String string)
quote
if (string == null || string.length() == 0) {
    return "\"\"";
char c = 0;
int i;
int len = string.length();
StringBuilder sb = new StringBuilder(len + 4);
String t;
...
Stringquote(String string)
quote
StringBuffer ret = new StringBuffer(string.length() + 2);
ret.append('\"');
for (char character : string.toCharArray()) {
    switch (character) {
    case '"':
        ret.append('\\');
        ret.append('"');
        break;
...
Stringquote(String string)
Given a string, wrap it in quotes (") if that string contains spaces
if (string.indexOf(' ') != -1)
    string = "\"" + string + "\"";
return string;