Ant runtime output encoding? How to use UTF-8?

I have a file encoded in UTF-8 that I want to read in java, change some things in the input file and print the result to the terminal (standard output) and to another file. I read and write files and write stdout with streams created to interpret the UTF-8 encoding.

Everything is fine, when I manually compile and run everything, the output file contains UTF-8 characters, stdout also outputs them to the terminal.

The problem is when I want to compile and run the program using ant. The output (written to the terminal) generated by ant does not seem to use UTF-8 characters, as Polish diacritics change to "?". Is there a way to force ant to use UTF-8? Also, can I somehow check which encoding is currently in use?

I searched for the answer, but all I found was to make ant interpret UTF-8 encoded java files.

+4
source share
1 answer

You can try setting -Dfile.encoding=UTF-8 , this will set the encoding to UTF-8.

You can also check if your console encoding is UTF-8 (OS dependent).

+3
source

Source: https://habr.com/ru/post/1383138/


All Articles