Java Utililty Methods String Unquote

List of utility methods to do String Unquote

Description

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

Method

StringunquoteString(String s)
unquote String
if (s.charAt(0) == '\"') {
    if (s.charAt(s.length() - 1) == '\"') {
        return (s.substring(1, s.length() - 1));
    return (s.substring(1, s.length() - 0));
if (s.charAt(s.length() - 1) == '\"') {
    return (s.substring(1, s.length() - 1));
...
StringunquoteString(String value)
If the value is an HTTP quoted-string then we strip of the quote characters now and translate any escaped characters into themselves, e.g., '\"' => '"'.
String originalValue = value; 
if (!value.startsWith("\"")) {
    return value;
if (!value.endsWith("\"")) {
    throw new IllegalArgumentException("Quoted string does not end with '\"'" + " : " + originalValue);
value = value.substring(1, value.length() - 1);
...
StringunquoteText(String s)
unquote Text
if (s == null || s.length() == 0) {
    return null;
if (s.charAt(0) == '\'' && s.charAt(s.length() - 1) == '\'') {
    s = s.substring(1, s.length() - 1);
} else if (s.charAt(0) == '"' && s.charAt(s.length() - 1) == '"') {
    s = s.substring(1, s.length() - 1);
return s;
StringunquoteXML(String xmlFragment)
A convenience method that allows for XML fragments, previously quoted with the #quoteXML(String) method to be unqoted again.
if (xmlFragment.startsWith(XML_QUOTE_PREFIX)) {
    return (xmlFragment.substring(XML_QUOTE_PREFIX.length(),
            xmlFragment.length() - XML_QUOTE_SUFFIX.length()));
return xmlFragment;