Package org.apache.commons.codec.net

Examples of org.apache.commons.codec.net.URLCodec.encode()


     * @return The string encoded for a URI
     */
    public static String sanitizeForURI(String str) {
      URLCodec codec= new URLCodec();
      try {
        return codec.encode(str).replaceAll("\\+", "%20");
      }
      catch (EncoderException ee) {
        logger.warn("Error trying to encode string for URI", ee);
        return str;
      }
View Full Code Here


    }
   
    public static String sanitizeAndPreserveSlashes(String str) {
      URLCodec codec= new URLCodec();
      try {
        return codec.encode(str).replaceAll("\\+", "%20").replaceAll("%2F", "/");
       }
      catch (EncoderException ee) {
        logger.warn("Error trying to encode string for URI", ee);
        return str;
      }
View Full Code Here

            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));
                }
            }
View Full Code Here

                    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

     * @throws Exception
     */
    public static String encode(String value) throws Exception {
      URLcodecTK.checkNull(value);
      URLCodec url = new URLCodec();
        return url.encode(value);
    }
   
    /**
     * ����w���줸�հ}�C�i��URL�s�X�A�æ^�ǽs�X���G.
     * �p�G�ѼƬ�null�A�h�ߥXCodecRuntimeException.
 
View Full Code Here

     * @throws Exception
     */
    public static byte[] encode(byte[] binaryData) throws Exception {
      URLcodecTK.checkNull(binaryData);
      URLCodec url = new URLCodec();
        return url.encode(binaryData);
    }

    /**
     * ����w���줸�հ}�C�i��URL�s�X�A�æ^�ǽs�X���G.
     * �p�G�ѼƬ�null�A�h�ߥXCodecRuntimeException.
 
View Full Code Here

     */
    public static String encode(String pString, String charset) throws Exception {
      URLcodecTK.checkNull(pString);
      URLcodecTK.checkNull(charset);
      URLCodec url = new URLCodec();
      return url.encode(pString, charset);
    }
   
   
    /**
     * ����w���줸�հ}�C�i��URL�ѽX�A�æ^�ǸѽX���G.
 
View Full Code Here

    }

    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

    }

    private static String encode(String object, boolean preserveslashes) {
        URLCodec codec = new URLCodec();
        try {
            final String encoded = codec.encode(object).replaceAll("\\+", "%20");
            if(preserveslashes) {
                return encoded.replaceAll("%2F", "/");
            }
            return encoded;
        }
View Full Code Here

            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));
                }
            }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.