Use the system property "file.encoding" mentioned in the java tutorial
and in the javadoc for OutputStreamWriter in JDK 1.2.2. I note that this
documentation has been removed in more recent JDKs, suggesting that it
is not an officially supported mechanism. (By the way, rumor has
it that the fact that this property is the default encoding is tested
for in the java certification exams).
Name: nl37777 Date: 11/01/2002
A better workaround is to use the code
OutputStream out = new ByteArrayOutputStream();
String defaultIOEncoding = (new OutputStreamWriter(out)).getEncoding();
This will return the old java.io canonical name for the character
encoding, which is not always the same as the java.nio canonical name,
but is always supported as an alias of the corresponding java.nio
charset. If the java.nio canonical name is desired, it can be obtained by
String defaultNIOEncoding = Charset.forName(defaultIOEncoding).name();
both old and new names.