Results 1 to 7 of 7
Thread: how to write onto a file
- 07-21-2007, 10:26 AM #1
Member
- Join Date
- Jul 2007
- Posts
- 8
- Rep Power
- 0
how to write onto a file
hi,
i m trying to write onto a file.Some of my text is in english and some in urdu.The problem that i m facing is i m able to write the english part correctly but not the urdu part.Here's my code..........
//urdu_synset contains the urdu string
//string1,string2,etc are english strings
fw=new FileWriter("news.txt",true);
fw.write(" \n" + "\n" + "ID :: " + string1 + "\n");
fw.write("CAT :: " + string2 + "\n");
fw.write("CONCEPT :: " + string3 + "\n");
fw.write("EXAMPLE :: " + string4 + "\n");
fw.write("SYNSET-URDU :: ");
fw.close();
fos=new FileOutputStream("news.txt",true);
osw=new OutputStreamWriter(fos,"Unicode");
osw.write(urdu_synset);
osw.flush();
i tried writin the urdu string into a different file using OutputStreamWriter in "unicode" format and it worked fine.....but it 's not workin out here....the string comes out to be garbled...........................
please suggest any suitable solution to my problem.....
- 09-18-2008, 07:35 AM #2
Member
- Join Date
- Sep 2008
- Posts
- 9
- Rep Power
- 0
Am Also Having Like The Poblem
- 09-18-2008, 08:27 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 09-18-2008, 08:30 AM #4
Senior Member
- Join Date
- Aug 2008
- Posts
- 384
- Rep Power
- 5
Use BufferedWriter.
I die a little on the inside...
Every time I get shot.
- 10-22-2008, 09:19 AM #5
Hi,
this works for me for different languages started from Russian ended with Cantonese.
Java Code:String fileName = "......"; OutputStream fout = new FileOutputStream(fileName); OutputStream bout = new BufferedOutputStream(fout); OutputStreamWriter fwr = new OutputStreamWriter(bout,"UTF-8");
TEAM = Together Everyone Achieves More :)
- 09-08-2009, 12:43 PM #6
Member
- Join Date
- Sep 2009
- Posts
- 6
- Rep Power
- 0
refer examples on java2examples.com
- 09-08-2009, 03:54 PM #7
if I'm not mistaken, special unicode characters have to be written out using their actual unicode i.e. \u00F6. Code Charts - Scripts has lists of all unicode characters, google helps too :D
Similar Threads
-
how do i write to a text file from an arraylist?
By otoro_java in forum New To JavaReplies: 3Last Post: 01-30-2008, 06:53 AM -
File Write Error
By vikain in forum Advanced JavaReplies: 5Last Post: 01-02-2008, 04:38 AM -
Write unicode into file
By vata2999 in forum New To JavaReplies: 1Last Post: 08-08-2007, 03:04 PM -
Help with write file in java
By mathias in forum New To JavaReplies: 1Last Post: 07-31-2007, 06:51 PM -
how to write the output of the console to a file
By fred in forum New To JavaReplies: 1Last Post: 07-24-2007, 02:02 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks