I get the following warning when using java.net.URLEncoder.encode
:
warning: [deprecation] encode(java.lang.String) in java.net.URLEncoder has been deprecated
What should I be using instead?
I get the following warning when using java.net.URLEncoder.encode
:
warning: [deprecation] encode(java.lang.String) in java.net.URLEncoder has been deprecated
What should I be using instead?
You should be using the other method in the URLEncoder class: URLEncoder.encode(String, String)
. The first parameter is the String to encode; the second is the name of the character encoding to use (e.g., "UTF-8").