code: public static String encodeHttpParams(String str)
      {
          if (str == null) {
              return "";
          }
          StringBuffer buf = new StringBuffer();
          char[] array = str.toCharArray();
          for (int i = 0; i < array.length; i++) {
              char ch = array[i];
              if ((ch >= 'a' && ch <= 'z')
                  || (ch >= 'A' && ch <= 'Z')
                  || (ch >= '0' && ch <= '9')
                  || Character.isDigit(ch)
                  || Arrays.binarySearch(HTTP_RESERVED_SYMBOLS, ch) >= 0
                  || Arrays.binarySearch(HTTP_UNRESERVED_SYMBOLS, ch) >= 0)
              {
                  buf.append(array[i]);
              } else {
                  buf.append("%" + Integer.toHexString(array[i]));
              }
          }
          return buf.toString();
      }
docs: Returns the encoded string - all special symbols will be replaced by
  %[HEX HEX] sequence, where [HEX HEX] is the hexadecimal code of the
  escaped symbol (see RFC-2616
  http://www.w3.org/Protocols/rfc2616/rfc2616.html).
  
  @param str the string to encode
  @return the encoded string.