Tag: deprecated
URLEncoder.encode is Deprecated So What Do I Use for Encoding?
by Frank Kim on Oct.31, 2009, under Java SE
(Photo: The Surface by Daniel*1977)
URLEncoder.encode(String url) is deprecated. Java wants you to use URLEncoder.encode(String url, String enc). But what do you put for the encoding parameter? I always forget which is the whole point of this post.
URLEncoder.encode(url, "UTF-8");
Also on Windows if you want you can do:
URLEncoder.encode(url, "Cp1252");
For further reading please see default encoding of a jvm.
