This question has already been answered:

Faced the problem of reading from a file: when displaying the contents of a file in the console instead of Cyrillic it shows such characters example

In Intelij IDEA, the UTF-8 encoding is everywhere (in the file, settings), the current code page in the Windows console is 866.

Who faced a similar problem?

Marked as a duplicate by the participants Mikhail Vaysman , Cheg , br3t , ߊߚߤߘ , αλεχολυτ 1 Aug '17 at 18:28 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • one
    everyone came across this. This is a known issue for windows. - Mikhail Vaysman

1 answer 1

Try to specify the encoding when opening the file:

try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("some_file.txt"), "utf-8"))) { String line; while ((line = br.readLine()) != null) { System.out.println(line); } } catch (IOException exc) { exc.printStackTrace(); } 
  • 2
    If java> = 1.7, then instead of "utf-8" I would advise using StandardCharsets.UTF_8 - Dmitry Igorevich