I have a csv file with characters like Cité
, but after make the insert into the DB, I see this Cit¿
I open the file as a BufferedReader
, but I don't know how to do it in UTF-8
BufferedReader br = new BufferedReader(new FileReader(csvFile));
You could explictly use a FileInputStream
and an InputStreamReader
using StandardCharsets.UTF_8
, but it's probably simpler to use Files.newBufferedReader
:
Path path = Paths.get(csvFile);
try (BufferedReader reader = Files.newBufferedReader(path)) {
// Use the reader
}
It's worth getting to know the Files
class as it has a bunch of convenience methods like this.
See more on this question at Stackoverflow