D
D
Danil2021-05-17 08:08:35
Java
Danil, 2021-05-17 08:08:35

FileInputStream encoding for ANCI?

There is a method that implements the BufferedReader construction filePathReader = new BufferedReader(new InputStreamReader(new FileInputStream(reader.readLine()))
The program must read a text file and output its contents to the console, the construction described above takes FileInputStream(reader.readLine()) as parameters )), reader.readline() - the path to the text file
Next, through the loop, I display the contents of the file to the console character-by-character
The problem is that the program does not read Cyrillic, displays a question mark instead of letters
Latin outputs norms
If you save a text file with utf8 encoding, then everything is OK
But how to read exactly for ansi

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-05-17
@Danicimo

You need to read the file in the encoding in which it is saved. If the encoding is not set explicitly, the system encoding is used.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question