This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "platform Watch "platform New topic
Author

platform's default character encoding

Alik Elzin
Greenhorn

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:

PCS


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"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Alik,
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.
Thanks,
Cindy


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

Joined: Jan 30, 2000
Posts: 18671
On many systems, it's possible to get the default encoding thus:
System.getProperty("file.encoding")
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
 
 
subject: platform's default character encoding