views:

721

answers:

3

Possible Duplicate:
What is the default encoding of jvm?

Hello,

what is the default character encoding in Java, when used to process text data?

I have browsed quite a while, however, I cannot find an answer (or I am not searching properly). I have text data, which was downloaded from web pages. Java was used for this, and the default encoding to process everything. I mean, during the whole process (downloading) no encoding was specified, and I assume there must be some default one. Which one? Thank you.

A: 

you can specify the default encoding on the command line when the app is started

java -Dfile.encoding=UTF8 au.com.objects.MyClass

If nothing is specified then the default is got from the underlying OS as AlbertoPL explains above.

objects
A: 

The default is the derived from the underlying OS. It can be overridden by a system property (file.encoding).

Since both of these are kind of outside of your control, it is probably better to explicitly specify an encoding for all the files your program writes and read. UTF-8 should work in most cases.

Thilo