private static String addQuotes(String s){
  int n=s.length();
  int i;
  char c;
  StringBuffer result=new StringBuffer(n + 2);
  result.append('\"');
  for (i=0; i < n; ++i) {
    c=s.charAt(i);
    if (c == '\"') {
      result.append('\\');
    }
    result.append(c);
  }
  result.append('\"');
  return result.toString();
}

private static String addQuotes ( String s ) { int n = s . length ( ) ; int i ; char c ; StringBuffer result = new StringBuffer ( n + 2 ) ; result . append ( '\"' ) ; for ( i = 0 ; i < n ; ++ i ) { c = s . charAt ( i ) ; if ( c == '\"' ) { result . append ( '\\' ) ; } result . append ( c ) ; } result . append ( '\"' ) ; return result . toString ( ) ; }
returns a version of the string surrounded by quotes and with interior quotes preceded by a backslash .
