Get the default character set of the JVMTag(s): IO Internationalization


public class Hello {
 public static void main(String args[]) throws Exception{
  // not crossplateform safe
  System.out.println(System.getProperty("file.encoding"));
  // jdk1.4
  System.out.println(
     new java.io.OutputStreamWriter(
        new java.io.ByteArrayOutputStream()).getEncoding()
     );
  // jdk1.5
  System.out.println(java.nio.charset.Charset.defaultCharset().name());
  }
}
Output example (winXP)
>java Hello
Cp1252
Cp1252
windows-1252
See also java encoding table for the encoding sets supported.
blog comments powered by Disqus