Java Utililty Methods CSV String Escape

List of utility methods to do CSV String Escape

Description

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

Method

StringcsvEscape(String str)
csv Escape
if (str == null) {
    return str;
str = str.replaceAll("\"", "\"\"");
return str;
StringcsvEscapeXML(String value)
csv Escape XML
StringBuilder tag = new StringBuilder();
for (char c : value.toCharArray()) {
    switch (c) {
    case '&':
        tag.append("&");
        break;
    case '<':
        tag.append("&lt;");
...
StringcsvFormat(Object... obj)
csv Format
String retval = "";
for (Object o : obj) {
    if (retval.length() > 0) {
        retval += ",";
    if (o == null) {
        o = "";
    String s = o.toString();
    s = s.replaceAll("\\\\", "\\\\\\\\");
    s = s.replaceAll("\"", "\\\"");
    retval += "\"" + s + "\"";
return retval;
StringCSVFormat(String data)
CSV Format
return "\"" + data + "\", ";