码迷,mamicode.com
首页 > 编程语言 > 详细

Java的默认编码

时间:2016-11-04 16:47:15      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:public   object   null   zed   rmi   local   for   src   system   

摘要:    
  1.Java的默认编码
内容:
1.Java的默认编码 
java的src.zip包中的java.nio.charset.Charset类中defaultCharset()方法说明java的编码类型是有jvm的file.encoding参数决定的,如果未指定默认是UTF-8
/**
* Returns the default charset of this Java virtual machine.
*
* <p> The default charset is determined during virtual-machine startup and
* typically depends upon the locale and charset of the underlying
* operating system.
*
* @return A charset object for the default charset
*
* @since 1.5
*/
public static Charset defaultCharset() {
if (defaultCharset == null) {
synchronized (Charset.class) {
String csn = AccessController.doPrivileged(
new GetPropertyAction("file.encoding"));
Charset cs = lookup(csn);
if (cs != null)
defaultCharset = cs;
else
defaultCharset = forName("UTF-8");
}
}
return defaultCharset;
}

Java的默认编码

标签:public   object   null   zed   rmi   local   for   src   system   

原文地址:http://www.cnblogs.com/arachis/p/JAVA_CharSet.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!