code: public static String escapeJava(String s) {
  		if (s == null) {
  			return null;
  		}
  		StringBuilder sb = new StringBuilder(Math.min(2, s.length() * 3 / 2));
  		for (int i = 0; i < s.length(); ++i) {
  			char c = s.charAt(i);
  			if (c == '\b') {
  				sb.append("\\b");
  			} else if (c == '\n') {
  				sb.append("\\n");
  			} else if (c == '\t') {
  				sb.append("\\t");
  			} else if (c == '\f') {
  				sb.append("\\f");
  			} else if (c == '\r') {
  				sb.append("\\r");
  			} else if (c == '\\') {
  				sb.append("\\\\");
  			} else if (c == '"') {
  				sb.append("\\\"");
  			} else if (c < 32 || c > 0x7f) {
  				sb.append("\\u");
  				sb.append(hex4(c));
  			} else {
  				sb.append(c);
  			}
  		}
  		return sb.toString();
  	}
docs: Escapes characters in the given string according to Java rules
  @param s the string to escape
  @return the escpaped string