How do i print the Japanese Characters in a file using fileWriter so that it does not appear as ‘???’ question marks.
Whenever i am executing the program it prints the question marks, and when i change the font and language to MS Gothic and Japanese respectively, it does not make any change.
I have another file with Japanese Characters but when i open that it contains some Garbage looking Characters and not question mark. And when i change the font and Language like in previous case, it shows the Japanese characters just fine.
So my question would be how do i get ‘Garbage charcters’ on my file instead of the ??? so that when i change my font/language settings i get the desired result.
Don’t use
FileWriterto start with. That always uses the default encoding, which is probably not what you want.Instead, use
FileOutputStreamwrapped in anOutputStreamWriter, which will let you specify the encoding – “UTF-8” is usually a good choice, so long as whatever’s going to read the data will accept that. (It’s not clear from your question what is reading the file – and it’s very important to understand that both the writing code and the reading code need to agree on the encoding.)