如何在java中解码URL实体?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16306607/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do decode URL entities in java?
提问by basteez
I'm trying to decode html entities in Java, but I noticed that
我正在尝试用 Java 解码 html 实体,但我注意到
URLDecoder.decode(String stringToDecode, String charset);
is deprecated.
已弃用。
What should I use instead of it?
我应该用什么来代替它?
采纳答案by Lars Juel Jensen
The method you mention is not deprecated. See here -> http://docs.oracle.com/javase/7/docs/api/java/net/URLDecoder.html
您提到的方法没有被弃用。见这里-> http://docs.oracle.com/javase/7/docs/api/java/net/URLDecoder.html
URLDecoder.decode(String stringToDecode)
on the other hand is.
另一方面是。
回答by Reimeus
It's not deprecated. The overloaded decode method that doesn't take a character encoding argument is deprecated.
它没有被弃用。不推荐使用不接受字符编码参数的重载 decode 方法。
回答by asifsid88
It is not deprecated. The decode method with two parameters is not deprecated. Please check again. The first parameter is the String to decode; the second is the name of the character encoding to use (e.g., "UTF-8").
它没有被弃用。不推荐使用带有两个参数的 decode 方法。请再次检查。第一个参数是要解码的字符串;第二个是要使用的字符编码的名称(例如,“UTF-8”)。
Refer: http://docs.oracle.com/javase/6/docs/api/java/net/URLDecoder.html
参考:http: //docs.oracle.com/javase/6/docs/api/java/net/URLDecoder.html