Solved

How to convert a OutputStreamWriter to FileOutputStream/OutputStream ?

Posted on 2001-06-04
5
1,150 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 100 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now