开发者

Reading hebrew from text file with Java

开发者 https://www.devze.com 2023-03-03 17:58 出处:网络
I\'m having 开发者_Go百科troubles with reading a UTF-8 encoded text file in Hebrew. I read all Hebrew characters successfully, except to two letters = \'מ\' and \'א\'.

I'm having 开发者_Go百科troubles with reading a UTF-8 encoded text file in Hebrew. I read all Hebrew characters successfully, except to two letters = 'מ' and 'א'.

Here is how I read it:

    FileInputStream fstream = new FileInputStream(SCHOOLS_LIST_PATH);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;

// Read File Line By Line
while ((strLine = br.readLine()) != null) {

                if(strLine.contains("zevel")) {

                    continue;
                }

                schools.add(getSchoolFromLine(strLine));
}

Any idea?

Thanks, Tomer


You're using InputStreamReader without specifying the encoding, so it's using the default for your platform - which may well not be UTF-8.

Try:

new InputStreamReader(in, "UTF-8")

Note that it's not obvious why you're using DataInputStream here... just create an InputStreamReader around the FileInputStream.

0

精彩评论

暂无评论...
验证码 换一张
取 消