Where does java get the default encoding from?

where does java get the default encoding from?

I tried the following code on two records: redhat 4 and centos 5

public class EncodingTest { public static void main(String args[]) throws Exception{ System.out.println(System.getProperty("file.encoding")); System.out.println( new java.io.OutputStreamWriter( new java.io.ByteArrayOutputStream()).getEncoding() ); } } 

I have two different results: redhat UTF-8 and for centos ASCII. This is the same installation and version of java (1.4). I run java without the -Dfile.encoding parameter.

Thanks.

+4
source share
1 answer

The default platform font is taken from the OS and depends on the default locale. If you get different results on different machines, these machines have different default language standards. Now it depends on your needs. If you want your application to work exactly the same as on the whole platform, pass the encoding with -Dfile.encoding

+2
source

All Articles