Learning Java. Created a project using Maven. I make a conclusion to the console of certain information in Russian + I write the same information to a file. When I launch IDEA, everything is fine, everything works as it should. Russian text in the file and in the console is displayed normally. But when I compile to jar, I run java -jar myprogramm.jar
from the Windows console, the output to the console is normal, and writes this to the file
GARDEN, 42, 620024 ESTIMATE, COMPOSITION
For some reason, the file is saved in windows 1252 encoding (at least this is indicated by sublime).
mavena settings
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
I FileWriter writer = new FileWriter(stringDate() + ".txt", true)
to the file via FileWriter writer = new FileWriter(stringDate() + ".txt", true)
When I do through PrintWriter writer = new PrintWriter(new File(stringDate() + ".xml"), "UTF-8");
where I forcibly specify UTF-8, then everything is fine, but there is no append
method in PrintWriter
.
Tell me how to get out of this?
Later tried to add to the maven
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
the file is created in UTF-8, but Russian characters are replaced by question marks ????
I don’t know what to do, thanks for any help.