code: public static String escapeCsvStr(String str) {
          if (str != null && !str.equals("")) {
              boolean needQuote = false;
              if (str.contains("\"")) {
                  str = str.replaceAll("\"", "\"\"");
                  needQuote = true;
              }
              if (!needQuote && str.contains(",")) {
                  needQuote = true;
              }
              if (needQuote) {
                  str = "\"" + str + "\"";
              }
              return str;
          } else {
              return "";
          }
      }
docs: CSV Escape handling for given string.
  " -> ""
  , -> ","
  
  @param str The string will be escaped for CSV format output
  @return Escaped CSV string