Forums Register Login

Reading Japanese Characters from Text File

+Pie Number of slices to send: Send
Hi,
I have a text file where the text is written in Japanese. While I want to read the file using Java it can not recognise the japanese characters and it is giving "???" like characters instead of Japanese characters.

FileInputStream fis = new FileInputStream("out.txt");
InputStreamReader isr = new InputStreamReader(fis,"UTF-8");

Reader in = new BufferedReader(isr);

StringBuffer buf = new StringBuffer();
int ch;
while ((ch = in.read()) > -1) {
buf.append((char)ch);
}
in.close();

String message = new String(buf.toString()); // Here i want the japanese characters to appear
System.out.println(message);

I have also tried "Shift_Jis" encoding isnstead of "UTF-8" encoding also.

Thanks in advance.
Regards,
Souvik
I don't even know how to spell CIA. But this tiny ad does:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 3611 times.
Similar Threads
Problem while Reading Japanese Characters from a Text File
Setting strings explicitly and using JOptionPane - UTF Character conversion problems...
How can I get Unicode String of a String?
readUTF not working
file, UTF8
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 05:52:55.