I need to allow user to input various special characters, so i use the java URLDeacoder.decode() method, i tested using println. There is no problem with other special character except this Percentage symbol, it has error during execute. Why is that? I understand that % is being used for URL encoding, is this the reason?
java.lang.IllegalArgumentException: URLDecoder: Incomplete trailing escape (%) pattern
System.out.println(URLDecoder.decode("%", "UTF-8"));
Despite their names, URLEncoder/Decoder are for encoding POST arguments, not URLs. See @fge's remarks below.
The way to encode a URL is with the URL and URI classes.
I'm curious as to how you acquired an undecoded URL in the first place.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With