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