hieutran42
hieutran42

Reputation: 75

How to preserve special symbols when reading in a file in Java?

I am trying to read in a file that has special symbols like: - l"Université - Borély

But Java is outputting things like: - l"université - Borely

Is there a way to read in a file that would preserve any special symbols? What format should the file be?

Thanks,

Upvotes: 1

Views: 1017

Answers (2)

alain.janinm
alain.janinm

Reputation: 20065

Maybe your looking for the Latin1 ISO. Try something like that:

BufferedReader inputStream = new BufferedReader(new InputStreamReader(
                                   new FileInputStream(file), "ISO-8859-1"));

Upvotes: 0

duffymo
duffymo

Reputation: 308733

All should be well if you use UTF-8 encoding when you write and read the file.

Upvotes: 2

Related Questions