Java Virtual machine file encoding parameters-dfile.encoding

Source: Internet
Author: User

Recently used idea to write something to find the call system cmd/k dir returned the string displayed there are a lot of garbled, obviously UTF8 and GBK to Chinese processing there are differences.
Think about it. Windows took a GBK encoding, so the idea of virtual machine run parameters plus-DFILE.ENCODING=GBK can be resolved.
-dfile.encoding explains:

At the command line, enter Java, and the-D description appears in the prompt given:
-d= # Set a system property
-D followed by a key-value pair, which is to set a system property
For-dfile.encoding=utf-8, it's about setting system Properties file.encoding for UTF-8.
So what does file.encoding mean. Literal meaning is file encoding.
Search Java source code, can only find 4 files containing file.encoding files,
In other words, only four files call the File.encoding property.
In the Charset.java of the Java.nio.charset package, the meaning of this passage is very clear.
Simply put, the default character set is determined when the Java Virtual machine is started.
Depends on the locale and character set of the operating system where the Java virtual machine resides.
As you can see in the code, the default character set is obtained from the file.encoding attribute.

Quote: http://blog.sina.com.cn/s/blog_4ce8808d0101d0i1.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.