Connecting Tech Pros Worldwide Help | Site Map

writing unicode character in text file

Newbie
 
Join Date: Oct 2008
Posts: 26
#1: Jul 3 '09
Hi,

I am trying to write japanese character in text file (actually trying to create a shell file), to execute some exe placed at that location.
Please help me with this, i need some solution very urgently.

fyi, i am using this code to read unicode character from another file.

String triggerFilePath = "/" + "BuildCopy" + File.separator + "Trigger.txt";
//http://bytes.com/groups/java/16986-how-specify-encoding-java
InputStream is = new BufferedInputStream(new FileInputStream(triggerFilePath));
Reader reader = new InputStreamReader(is, "UTF-8");
BufferedReader dataFile= new BufferedReader(reader);
String currentRecord = dataFile.readLine();


thanks in advance,
Rahul
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#2: Jul 3 '09

re: writing unicode character in text file


Quote:

Originally Posted by rahullko05 View Post

I am trying to write japanese character in text file (actually trying to create a shell file), to execute some exe placed at that location.
Please help me with this, i need some solution very urgently.

Although it may be urgent to you, it isn't urgent to us; btw, you mentioned writing characters to a file but all I see is InputStreams and Readers; they are for reading (from a file).

kind regards,

Jos
Newbie
 
Join Date: Oct 2008
Posts: 26
#3: Jul 4 '09

re: writing unicode character in text file


i have just given the code which i am using to read the file containing unicode characters. where i am stuck is how to write a file with same unicode characters contained in string.
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#4: Jul 4 '09

re: writing unicode character in text file


Quote:

Originally Posted by rahullko05 View Post

i have just given the code which i am using to read the file containing unicode characters. where i am stuck is how to write a file with same unicode characters contained in string.

It's exactly the same but the other way around, so you have to use a FileOutputStream, an OutputStreamWriter and a BufferedWriter. btw, you're buffereing to much in your reading procedure: you buffer the stream and the reader; that doesn't help you much, buffer only once.

kind regards,

Jos
Reply