加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

系统属性file.encoding在JVM启动后,再次设置无法对系统的默认编

发布时间:2020-12-15 07:51:31 所属栏目:Java 来源:网络整理
导读:?原因和解决方法: ? ?https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4163515 ? ?https://stackoverflow.com/questions/361975/setting-the-default-java-character-encoding/362006#362006 ? file.encoding由谁设置? 首先file.encoding是一个系统

?原因和解决方法:

?

?https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4163515

?

?https://stackoverflow.com/questions/361975/setting-the-default-java-character-encoding/362006#362006

?

file.encoding由谁设置?

    首先file.encoding是一个系统属性。可以在启动JVM?前设置?如:

  java -Dfile.encoding=UTF-8 xxx.class

    还有一种方法是改变操作系统的系统区域,因为在JVM启动时如果没有设置此属性时,默认根据系统区域(locale)选择编码方式.

?

  区域为中国时,file.encoding为GBK

? ? ? ??

?

?

? ? ? ??

?

?

?

?  区域为美国时,file.encoding为Cp1252

  

? ? ? ?

?

?

?  在JDK1.8中只有搜索到四处引用了file.encoding

? ? ? ??

?

  JVM的默认编码方式:Charset.defaultCharset()

? ? ? ?

?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读