Friday, January 6, 2012

java URLEncoder

import org.apache.commons.codec.EncoderException;
import org.apache.commons.codec.net.URLCodec;

public static String encodeURL(String url) {
try {
return new URLCodec().encode(url);
} catch (EncoderException e) {
return null;
}
}

or
String inputEnc= URLEncoder.encode(input,"UTF-8"); // jakarta-commons/commons-codec.jar

No comments: