N
N
NameOf Var2017-03-15 12:19:43
Java
NameOf Var, 2017-03-15 12:19:43

How to display Cyrillic text from a file?

It is required to display the contents of the file, which contains both Latin and Cyrillic.

try (BufferedReader fin = new BufferedReader(new FileReader(args[args.length - 1]))) {
            while ((currLines = fin.readLine()) != null) {
                System.out.println(currLines);
            }
        }
        catch (FileNotFoundException error) {
            System.out.println("File " + args[args.length - 1] + " not found.");
            System.exit(0);
        }

In this case, the program outputs ������ ���� ������

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2017-03-15
@hax

new InputStreamReader( new FileInputStream(filename), "cp1251"))
Explicit encoding.

B
b3er, 2017-03-15
@b3er

Most likely the matter is in the encoding, FileReader uses the default encoding, you can use InputStreamReader to specify the encoding . Also, the problem may be with the terminal where the program writes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question