File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes platform's default character encoding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "platform Watch "platform New topic

platform's default character encoding

Alik Elzin

Joined: Sep 19, 2002
Posts: 15
Hi all.
How can I get the platform's default character encoding ?
Philip Shanks
Ranch Hand

Joined: Oct 15, 2002
Posts: 189
From Sun's Java site:
You can query an InputStreamReader or OutputStreamWriter (these are the classes that "bridge" byte streams to character streams), for its character encoding.
For example:

Now you have a String representation of the encoding.
This example would work in an applet too:


Philip Shanks, SCJP - Castro Valley, CA
My boss never outsources or has lay-offs, and He's always hiring. I work for Jesus! Prepare your resume!
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Please change your name to be compliant with JavaRanch's naming policy.
Your displayed name should be 2 separate names with more than 1 letter each. We really would prefer that you use your REAL name.
You can change your name: here.

"JavaRanch, where the deer and the Certified play" - David O'Meara
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
On many systems, it's possible to get the default encoding thus:
However this is not guaranteed to work on all systems. The simplest way I know that is guaranteed is
new OutputStreamWriter(System.out).getEncoding()

"I'm not back." - Bill Harding, Twister
I agree. Here's the link:
subject: platform's default character encoding
Similar Threads
UnInitialized Strings
Printwriter vs System.out.println()
Unicode & Platform's default character encoding
how to convert byte [] to String?