I
I
Irdisx12019-10-03 19:05:42
Java
Irdisx1, 2019-10-03 19:05:42

Java encoding problems, help?

There is a CSV file, you need to read a few lines from the end of it and send them to the server. When reading, Russian letters are displayed incorrectly. My attempts to change the encoding did not lead to anything, I tried 5 or 6 different ways (which I found in Google) - all to no avail. The CSV file itself was obtained by translating from the tps format (tps-to-csv.jar, google it if it helps). When translating as described, the standard encodes the CSV file in ISO-8859-1 format, but when the file is checked, the encoding turns out to be "windows-1251". When you try to change the encoding during translation (there is such a function) to UTF-8, the Russian letters in the CSV file already become unreadable.
If you change the encoding of the CSV file itself, and then read through java, everything becomes all right. Unfortunately, this option does not work, that's why I'm asking the question here.
Here is a piece of code (reading moment):

public static void main(String[] args) throws Exception
    {
        int counter = 0;
        String[] arr = new String[100];
        File file = new File("путь к файлу");
        ReversedLinesFileReader object =
                  new ReversedLinesFileReader(file);
        while(counter<100) {
            arr[counter] = object.readLine();
            System.out.println(arr[counter]);
            counter++;
        }
    }

The ReversedLinesFileReader class is located in -> apache commons-io
For tests, the CSV file can be downloaded here

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Alexandrov, 2019-10-03
@Irdisx1

ReversedLinesFileReader(File file, int blockSize, String encoding)
          Creates a ReversedLinesFileReader with the given block size and encoding.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question