Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

Writing an ArrayList object to a File with encoding

Thread view: 
Eren Aykin - 23 Apr 2006 16:32 GMT
Hi, I want to serialize and write an arraylist to a file, but the
problem is the strings in the arraylist needs to be encoded in
"windows-1254".
My current code is like:

FileOutputStream fout2= new FileOutputStream("C:\\vocabulary.txt");
ObjectOutputStream out2= new ObjectOutputStream(fout2);
out2.writeObject(vocArray); // vocArray is an arraylist

The words in the vocArray have some foreign language characters and
I've problem writing them to a file.
I know that OutputStreamWriter allows us to define encoding type so I
can write:
OutputStreamWriter osw2 = new OutputStreamWriter(out2,"windows-1254");

But I don't know how to write the arraylist object with a specific
encoding type.

Could anybody help me with this problem?
Lasse Reichstein Nielsen - 23 Apr 2006 17:04 GMT
> Hi, I want to serialize and write an arraylist to a file, but the
> problem is the strings in the arraylist needs to be encoded in
> "windows-1254".

Uhm, why?
Either you serialize the ArrayList, and then you can't expect anything
of the output except that it can be deserialized again, or you
write the content of the ArrayList in a format of your choice.

....

> The words in the vocArray have some foreign language characters and
> I've problem writing them to a file.

Serialization of strings should not have a problem at all. What
problems do you have?

/L
Signature

Lasse Reichstein Nielsen  -  lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
 'Faith without judgement merely degrades the spirit divine.'

Eren Aykin - 23 Apr 2006 17:43 GMT
Oh! I'm sorry Lasse, as you said I really don't have a problem with
serialization.  I just clicked on the serialized vocabulary.txt and saw
those awkward chars and thought that there must be a problem with
encoding.
I wish there was a way to delete my question, I think I need some fresh
air...
Thank you anyway.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.