Sunday, 24 April 2016

How to read UTF-8 encoded data from a file ?


Example

File fileDir = new File("c:\\temp\\test.txt");
BufferedReader in = new BufferedReader(new InputStreamReader(
                         new FileInputStream(fileDir), "UTF8"));

String str;
while ((str = in.readLine()) != null) {
  System.out.println(str);
}

in.close();

No comments:

Post a Comment

Note: only a member of this blog may post a comment.