I had finished a project in which I read from a text file written with notepad.
The characters in my text file are in Arabic language,and the file encoding type is UTF-8.
When launching my project inside Netbeans(7.0.1) everything seemed to be ok,but when I built the project as a (.jar) file the characters where displayed in this way: ÇáãæÇÞÚááÊØæíÑ.
How could I solve This problem please?
I had finished a project in which I read from a text file written
Share
Most likely you are using JVM default character encoding somewhere. If you are 100% sure your file is encoded using UTF-8, make sure you explicitly specify UTF-8 when reading as well. For example this piece of code is broken:
because it uses JVM default character encoding – which you might not have control over and apparently Netbeans uses UTF-8 while your operating system defines something different. Note that this makes
FileReaderclass completely useless if you want your code to be portable.Instead use the following code snippet:
You are not providing your code, but this should give you a general impression how this should be implemented.