Reputation: 11
I have a piece of code like this:
data = new String(Files.readAllBytes(Paths.get(strFileName)));
PrintWriter out = new PrintWriter(filename);
out.println(data);
When it writes...it's changing the quotation marks(and probably other stuff -- to what seems like gobbledy-gook. Maybe this is unsigned int stuff or something?
Here's the original: “4 hours TILL FULL MOON”
It changed to this: “4 hours TILL FULL MOON�
I should say there are other quotations in the file that didn't change...but several did(I know single quotes had a similar issue).
Upvotes: 0
Views: 163
Reputation: 396
You'll have to change
PrintWriter out = new PrintWriter(filename);
to
PrintWriter out = new PrintWriter(filename, "ISO-8859-1");
because printwriter by default will not use ISO-8859-1 encoding.
Upvotes: 0
Reputation: 40078
change encoding explicitly through PrintWriter
constructor, by default java might be using UTF-8
PrintWriter pw = new PrintWriter("filename", "ISO-8859-1");
Upvotes: 2