Solved

How to convert a OutputStreamWriter to FileOutputStream/OutputStream ?

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSumClump challenge 9 115
web services creation SOAP vs REST 5 40
map related example 6 47
Java: How do I open the default windows program for a given file type 3 28
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

770 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