protected String escape(String s){
  StringBuffer result;
  int i;
  char c;
  if ((s.indexOf('\"') > -1) || (s.indexOf('\\') > -1) || (s.indexOf('\b') > -1)|| (s.indexOf('\f') > -1)|| (s.indexOf('\n') > -1)|| (s.indexOf('\r') > -1)|| (s.indexOf('\t') > -1)) {
    result=new StringBuffer();
    for (i=0; i < s.length(); i++) {
      c=s.charAt(i);
      if (c == '\"') {
        result.append("\\\"");
      }
 else       if (c == '\\') {
        result.append("\\\\");
      }
 else       if (c == '\b') {
        result.append("\\b");
      }
 else       if (c == '\f') {
        result.append("\\f");
      }
 else       if (c == '\n') {
        result.append("\\n");
      }
 else       if (c == '\r') {
        result.append("\\r");
      }
 else       if (c == '\t') {
        result.append("\\t");
      }
 else {
        result.append(c);
      }
    }
  }
 else {
    result=new StringBuffer(s);
  }
  return result.toString();
}

protected String escape ( String s ) { StringBuffer result ; int i ; char c ; if ( ( s . indexOf ( '\"' ) > - 1 ) || ( s . indexOf ( '\\' ) > - 1 ) || ( s . indexOf ( '\b' ) > - 1 ) || ( s . indexOf ( '\f' ) > - 1 ) || ( s . indexOf ( '\n' ) > - 1 ) || ( s . indexOf ( '\r' ) > - 1 ) || ( s . indexOf ( '\t' ) > - 1 ) ) { result = new StringBuffer ( ) ; for ( i = 0 ; i < s . length ( ) ; i ++ ) { c = s . charAt ( i ) ; if ( c == '\"' ) { result . append ( "\\\"" ) ; } else if ( c == '\\' ) { result . append ( "\\\\" ) ; } else if ( c == '\b' ) { result . append ( "\\b" ) ; } else if ( c == '\f' ) { result . append ( "\\f" ) ; } else if ( c == '\n' ) { result . append ( "\\n" ) ; } else if ( c == '\r' ) { result . append ( "\\r" ) ; } else if ( c == '\t' ) { result . append ( "\\t" ) ; } else { result . append ( c ) ; } } } else { result = new StringBuffer ( s ) ; } return result . toString ( ) ; }
escapes " , / , \ b , \ f , \ n , \ r , \ t .
