J
J
Jsman2016-01-24 22:48:48
Java
Jsman, 2016-01-24 22:48:48

How to change the encoding in the response?

Good evening! The problem is the following, there is an xlsx file, I want to parse it, but initially I want to display the contents of the file to the console, but I get hieroglyphs =(
Where and how should I write the encoding?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Malyarov, 2016-01-24
@SeniorDmitry

FileInputStream fin = new FileInputStream("../OMEGANOV.ods")
DataInputStream in = new DataInputStream(fin);
String string = in.readUTF();
System.out.println(string);
PS Reassign the stream FileInputStream is needed for reading/writing. DataInputStream for encodings... Shmadirovki and other labuteni.

import java.io.*;

public class xlsPars {

        public static void main(String[] args) {

            try(FileInputStream fin = new FileInputStream("../ОМЕГАНОЯБРЬ.ods"))
            {
                int i = -1;
                while((i = fin.read())!=-1){
                    DataInputStream in = new DataInputStream(fin);
                    String string = in.readUTF();
                    System.out.println(string);
                }
            }
            catch(IOException ex){

                System.out.println(ex.getMessage());
            }
        }
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question