question: public static boolean quoteIfNeeded ( Appendable buf , String s , String delim ) { for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( delim . indexOf ( c ) >= 0 ) { quote ( buf , s ) ; return true ; } } try { buf . append ( s ) ; return false ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
target:  Quote a string into a StringBuffer only if needed. Quotes are forced if any delim characters are present.