Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

Problem with Japanese Encoding



Hi,
I am new to ja encoding formats in java. I have a code where I want to save ja lang text in a text file (.vcs - calander attachment). But I get junk characters instead of ja lang texts. I tried a small code snippet which I am not able to get it work.

String st = "japanese lang text here";
File fl1;
fl1 = new File("C:\\test.txt");
FileOutputStream fos1 = new FileOutputStream(fl1);
fos1.write(st.getBytes("SJIS"));
fos1.close();

Here this string st comes from another function. I use test.txt file for testing and "SJIS" is the encoding format in java for JA (Shift_JIS). I have attached the source.txt and the result test.txt.

Thanks for the help in advance.
Senthil