In the jdk documentation, the "file.encoding" system property is mentioned. However, where can I find the related documentation about this property? I am not trying ask here what this property means. Instead, I just want to know where is its documentation. I come across this term many times did some search but just could not find out its documentation. Is it some unofficial property that we should not bother with?
Remember that FileReader and FileWriter read and write 16-bit characters. However, most native file systems are based on 8-bit bytes. These streams encode the characters as they operate according to the default character-encoding scheme. You can find out the default character-encoding by using System.getProperty("file.encoding"). To specify an encoding other than the default, you should construct an OutputStreamWriter on a FileOutputStream and specify the encoding.
The file.encoding property really isn't properly documented. Yeah, it's mentioned in the tutorial, but it really should be documented in the API under System.getProperties() (like all standard properties are documented) - and it isn't. Here is the relevant RFE. Note that the problem is effectively solved now in JDK 5 using java.nio.charset.Charset.defaultCharset().name(). Prior to JDK 5, you can use new OutputStreamWriter(new ByteArrayOutputStream()).getEncoding(). Which is slightly convoluted, but it works.