Writting Greek text in xml file (without Netbeans) - issue.
Hi,
i have create a java program, which - generally - reads, put in a diferent hierarhy and writes some string to a xml file.
Some of the files have Greek characters. When i run it with (my personal favorite) Netbeans, all process is just fine.
But when i run it just from .jar (the same jar which netbeans create), then all Greek character look like more as ... hieroglyphics..
At start, i thought that it was my mistake. So i make this change at code:
Code :
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filePath),"UTF8"));
Unfortunally this make no difference. I try also to change encoding ("ISO8859_7" , "Cp1253") but result was the same and worse..
I concluded that something done by Netbeans and works the process correctly. Perchaps an option?
It is need to compile and run it with .bat file, so .. any ideas what should i do to fix this?
Thank you for your time.
Re: Writting Greek text in xml file (without Netbeans) - issue.
Try setting the character encoding of the OutputStreamWriter and corresponding InputStreamWriter to UTF-16
Re: Writting Greek text in xml file (without Netbeans) - issue.
Thank you for the answer.
I tried it but the results are the same..
I wonder if is there any option for the .bat file, to "drive" the writing of files on an specific encoding?
Re: Writting Greek text in xml file (without Netbeans) - issue.
Have you tried printing the characters on the console before writing them? It would be interesting to see if they are already scrambled. You can set the default charset with the option '-Dfile.encoding=UTF-8' or something like that.
Re: Writting Greek text in xml file (without Netbeans) - issue.
Quote:
Originally Posted by
Sean4u
Have you tried printing the characters on the console before writing them? It would be interesting to see if they are already scrambled.
I just try it. In the console of Netbeans appear normal. But in console (CMD) looks like in file, damaged.
After that, i open the file (xml) with the notepad, wordpad, notepad++. In any of those three the characters are ok.
Because of xml file, i use kXML2 pull parser to load my data. But,even if that parser ruin greek characters.. Should not be so in the Νetbeans?
Re: Writting Greek text in xml file (without Netbeans) - issue.
The reason I suggested you do that is to see whether the data is mangled on output or input. If it's mangled on the console then it must be mangled on input. Did you try the command-line setting for file.encoding?
Re: Writting Greek text in xml file (without Netbeans) - issue.
Problem Solved! I put - as you recommend - on bat file:
Set JAVA_TOOL_OPTIONS= -Dfile.encoding=UTF8
Thanks for all the help and guidance!