Java 为什么不推荐使用常量 HTTP.UTF_8?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24128120/
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
Why is the constant HTTP.UTF_8 deprecated?
提问by Peter Porter
After upgrading to Apache HttpClient >=4.2, I found the following constant now deprecated:
升级到 Apache HttpClient >=4.2 后,我发现以下常量现已弃用:
org.apache.http.protocol.HTTP.UTF_8
Why was this constant deprecated (along with others) and what is the Apache HttpClient recommended alternative? The a HttpCore javadoc herelists it as deprecated but does not recommend an alternative.
为什么不推荐使用这个常量(以及其他常量),Apache HttpClient 推荐的替代方案是什么?在一个的HttpCore的javadoc在这里将其列为弃用,但不建议替代。
采纳答案by Sotirios Delimanolis
Since Java 7, Java provides the StandardCharsetsclass for getting the Charsetobject for a few standard character sets. These are: ASCII, ISO-8859-1, UTF-8, UTF-16, UTF-16BE, and UTF-16LE. That's the alternative.
从 Java 7 开始,Java 提供了StandardCharsets用于获取Charset一些标准字符集的对象的类。它们是:ASCII、ISO-8859-1、UTF-8、UTF-16、UTF-16BE 和 UTF-16LE。那是另一种选择。
There's no longer a point in re-declaring the Stringname of the character set in an HTTPclass.
在类中重新声明String字符集的名称不再有意义HTTP。

