1

I have a CSV file and i have a problem with number formats, in my java code the double's have Locale loc = new Locale("hu", "HU"); format so in the program looks like 1 401,1 but in CSV it looks like 1Â 401,1 How can I set encoding? I'm using javacsv library

String outputFile = Calc.tf_file.getText();         
boolean alreadyExists = new File(outputFile).exists();

        try {

            CsvWriter csvOutput = new CsvWriter(new FileWriter(outputFile, true), ';');


            if (!alreadyExists)
            {
                csvOutput.write("Point");
                csvOutput.write("Price");
                csvOutput.endRecord();
            }


                        for (int i = 0; i < Calc.number_list.size(); i++) {                       
                        csvOutput.write(Calc.point_list.get(i));
                        csvOutput.write(Calc.number_list.get(i));
                        csvOutput.endRecord();
                    }


            csvOutput.close();

1 Answer 1

1

Change:

CsvWriter csvOutput = new CsvWriter(new FileWriter(outputFile, true), ';');

To:

CsvWriter csvOutput = new CsvWriter(outputFile, ';', Charset.forName("Cp1250"));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.