How to programatically set the text encoding for the interface of a java application? -


i building application using javafx which's interface supposed in spanish. many of information read files , displayed take accents , such. when run application on macosx works beautifully , seemlessly.

same happens if run on windows within ide (netbeans 8.0, jkd 8u11).

why, run app outside ide on windows 8.1, encoding apruptly changes ti display text filled replacement characters , how fix issue within code? possible or system variable user has assume?

also, judging window displayed on top of main window, problem occurs when reading text file , displaying it's content textarea.

this get:

this

this application defect. must specify encoding (charset) when converting bytes chars or vice-versa. - mcdowell.

you need specificy encoding inputstreamreader , rid of filewriter, uses default encoding, , use outputstreamwriter appropriate encoding instead. note if using java 7+ there easier ways read/write files. – assylias

yield solution:

br = new bufferedreader(new inputstreamreader(this.getclass().getclassloader().getresourceasstream(name+shortname+".txt"),charset.forname("utf-8")));  bw = new bufferedwriter(new outputstreamwriter(new fileoutputstream("presentaciones/"+shortname+"/"+shortname+".txt"), charset.forname("utf-8"))); 

...where utf-8 encoding needed preserve symbols such inverterquestionmark , accents... thank guys!!


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -