File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

create an OutPutStreamObject with out using files and which supports chinese characters

 
Apna Apana
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I need an OutPutStreamObject or even PrintWriter object with out using files and which supports chinese characters(unicode)

Thanks in Advance

 
Paul Clapham
Sheriff
Pie
Posts: 20196
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any OutputStream will support Chinese characters, or anything in the Unicode character set for that matter... only provided you specify the charset to be used to convert those characters to bytes. You would have to use that charset when you wrote data to the OutputStream, and if that data was subsequently used by somebody else, they would also have to use that charset to convert the bytes back to chars.

Is that sufficient to answer your question? Or was your question something else, but you thought OutputStream was the answer to that question but you couldn't figure out why?
 
Apna Apana
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,

First of all Thanks for you reply.
I know that Streams are capable of dealing with character data. But how can I create a OutPutStream writer object or PrintWriterObject with out using files.
Another question is if I use ByteOutputStream is chinese data going to be messed up as ???.

Thanks in Advance
 
Rob Spoor
Sheriff
Pie
Posts: 20388
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To properly handle non-ASCII characters, you should wrap any InputStream / OutputStream in a Reader / Writer. The InputStreamReader and OutputStreamWriter are excellent choices to start with, as they allow you to specify the encoding to use. You then simply write the characters to the Writer, which turns it into bytes that are written to the OutputStream. The other way around, when you ask the Reader to read a character it asks the InputStream for one or more bytes to convert into the requested character.

And whatever you do, don't write non-ASCII characters to System.out. The console is very limited in what it can display. That's not a limitation in the JVM but the system's console. Using JOptionPane.showMessageDialog(null, message) usually is better.
 
Apna Apana
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You Rob for detailed explanation
 
Rob Spoor
Sheriff
Pie
Posts: 20388
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic