Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to convert a OutputStreamWriter to FileOutputStream/OutputStream ?

Posted on 2001-06-04
5
Medium Priority
?
1,238 Views
Last Modified: 2011-08-18
Hi,

  I have an OutputStreamWriter object, I need to convert this object to a FileOutputStream(or OutputStream) object, so I can pass the this object to Properties.store method.

Someone knows how to do it ?

Thanks

Richard

0
Comment
Question by:richardluo
5 Comments
 
LVL 3

Expert Comment

by:Sendoh
ID: 6154611
hi !
just wondering in order for u to create a OutputStreamWriter obj(y) u need a OutputStream obj(x) ...
so just store and pass that x to properties.store loh...

hope this helps...:)
0
 

Author Comment

by:richardluo
ID: 6154662
Hi,

  I need to create an OutputStream with encoding, OutputStream object itself doesn't allow u to put encoding, so I need to create OutputStreamWriter with encoding first, then pass that object to store...

Any suggestion ?

Richard
0
 
LVL 92

Accepted Solution

by:
objects earned 300 total points
ID: 6154691
The Properties class only understands a particular format, Latin 1 encoding, with non-ascii charaters converted to unicode format (\uxxxx).
So the short answer is you can't use a specified encoding to save (or load) properties files.

There is a tool available from Sun (native2ascii) which convert Unicode-encoded files to native-encoded and visa versa:

http://java.sun.com/j2se/1.3/docs/tooldocs/tools.html#intl
0
 
LVL 3

Expert Comment

by:shyamkumarreddy
ID: 6155071
Hi Richard
U can use DataOutputStream and save in specified format.



Cheers
Shyam
0
 
LVL 3

Expert Comment

by:shyamkumarreddy
ID: 6155072
Just checkup the Document for DataOutputStream


Cheers
Shyam
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This video teaches viewers about errors in exception handling.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question