Java encoding issue with a txt file

Viewed 96

I am facing an issue while saving a text file in Java. I have coded instructions to create a file with information I want to keep in a text file. But when I want to open it, I have an error message which says that my file was loaded with the wrong encoding (UTF-8) and I can't get back the informations I want. I have tried to reload with others encoding like ISO8859-1 (which is supposed to work in most of the cases, but it didn't.

oos = new ObjectOutputStream(
                new BufferedOutputStream(
                        new FileOutputStream(
                                new File("game.txt"))));

Then I create my objects, and then I get back my datas.

ois = new ObjectInputStream(
                new BufferedInputStream(
                        new FileInputStream(
                                new File("game.txt"))));

I didn't find any way to solve my issue. Kindly help.

0 Answers
Related