UTF-8 file reading: the first character issue
807580May 18 2010 — edited May 25 2010Hi,
A file foo.sql is saved as UTF-8 encoding using Windows notepad.
Then the following code did not read the text content correctly.
InputStreamReader isr = new InputStreamReader(new FileInputStream("foo.sql"), "UTF-8");
BufferedReader reader = new BufferedReader(isr);
String line = reader.readLine();
From debug, the first character is not displayable. for example,
foo.sql
----------
create table school
the line from BufferedReader is
?create table school
the question mark means the char is not displayable. What is the correct way to read UTF-8 encoded text file?
Thanks for help.
Dave