Meaningless Drivel is fun!
The moose likes I/O and Streams and the fly likes NIO and Internationalization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "NIO and Internationalization" Watch "NIO and Internationalization" New topic

NIO and Internationalization

Lanny Gilbert
Ranch Hand

Joined: Jun 11, 2002
Posts: 104
Greetings from beautiful Sandy Springs, Georgia.
Since I'm studying for the SCEA exam, streams and internalization are on my mind quite a bit these days.
How does NIO provide for internationalization?
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
Mhh, it seems to me that NIO is mainly about the mechanics of writing/reading something, whereas i18n is about *what* to write. So, aren't that somewhat orthogonal issues?
What would you expect from NIO in regards to i18n?

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
In traditional IO, InputStreamReader and OutputStreamWriter provide for conversion between byte streams and character streams (Readers and Writers) using named character encodings. NIO has similar functionality provided by Charset, CharsetEncoder and CharsetDecoder. These do things like convert a ByteBuffer into a CharBuffer view and vice versa.

"I'm not back." - Bill Harding, Twister
Ron Hitchens
Ranch Hand

Joined: Mar 17, 2003
Posts: 30
As the previous posters have pointed out, NIO doesn't directly address I18N. There is a new package in NIO, java.nio.charset, which is all about character sets but it's concerned only with transcoding between character sequences and byte streams.
NIO is really only involved at the plumbing level in I18N. The Charset class let's you define your own character sets and gives you complete control over their endcoding/decoding rules.
Character sets you create may be added to the JVM for general use (including by Readers and Writers) but that's the extent of it. NIO knows nothing about Locales, number formatting conventions, etc.
So international character sets can be built and deployed with NIO. But if I18N is your thing, you'll probably not deal directly with NIO very often.

Author of <a href="" target="_blank" rel="nofollow">Java NIO</a> (<a href="" target="_blank" rel="nofollow"></a>)
I agree. Here's the link:
subject: NIO and Internationalization
It's not a secret anymore!