Package org.apache.commons.codec.net

Examples of org.apache.commons.codec.net.URLCodec


    }
  }
 
  // Encode www-form-url
  private static String encodeUrlCodec(final String encodeText) {
    final URLCodec codec = new URLCodec();
    try {
      return codec.encode(encodeText, "UTF-8");
    } catch (final UnsupportedEncodingException e) {
      return "Error: Sting input cannot be decoded";
    }
  }
View Full Code Here


     private static String doFormUrlEncode(NameValuePair[] pairs, String charset)
        throws UnsupportedEncodingException
     {
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < pairs.length; i++) {
            URLCodec codec = new URLCodec();
            NameValuePair pair = pairs[i];
            if (pair.getName() != null) {
                if (i > 0) {
                    buf.append("&");
                }
                buf.append(codec.encode(pair.getName(), charset));
                buf.append("=");
                if (pair.getValue() != null) {
                    buf.append(codec.encode(pair.getValue(), charset));
                }
            }
        }
        return buf.toString();
    }
View Full Code Here

        }
        return converted;
    }

    private static String encode(String object) {
        URLCodec codec = new URLCodec();
        try {
            return codec.encode(object).replaceAll("\\+", "%20");
        }
        catch(EncoderException ee) {
            return object;
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.codec.net.URLCodec

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.