I have some current code and the problem is its creating a 1252 codepage file, i want to force it to create a UTF-8 file
Can anyone help me with this code, as i say it currently works... but i need to force the save on utf.. can i pass a parameter or something??
this is what i have, any help really appreciated
var out = new java.io.FileWriter( new java.io.File( path )),
text = new java.lang.String( src || "" );
out.write( text, 0, text.length() );
out.flush();
out.close();
All of the answers given here wont work since java's UTF-8 writing is bugged.
http://tripoverit.blogspot.com/2007/04/javas-utf-8-and-unicode-writing-is.html
Try this
Since Java 7 you can do the same with
Files.newBufferedWriter
a little more succinctly:we can write the UTF-8 encoded file with java using use PrintWriter to write UTF-8 encoded xml
Or Click here
The Java 7 Files utility type is useful for working with files:
The Java 8 version allows you to omit the Charset argument - the methods default to UTF-8.