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 "" ; } }
CSV Escape handling for given string . - > - >