I have been writing some data import programs recently and have had trouble with foreign characters in a text file I was reading. The solution is in fact very simple. To create a BufferedReader for a file in UTF-8 format, simply write the following:

new BufferedReader(
    new InputStreamReader(
        new FileInputStream(file), UTF8));

 

Matt Reid

Lead Software Architect. Java/Node enthusiast, badminton lover, foodie.

drei01 Matthew_Reid


Published