Saturday, July 4, 2009

In Java, how do I set a default character encoding for file I/O operations

The default encoding used by locale/encoding sensitive API in the Java libraries is determined by the System property "file.encoding". This system property is initialized by the JVM startup code after querying the underlying native operating system. For example on my English USA NT box it is initialized to:


It is generally recommended that you do not modify it. However if you know what you are doing you could override the system property either on the command line using the -

java -Dfile.encoding=GBK -jar Speech.jar

syntax or programmatically at startup.

No comments: