简体   繁体   English

使用Java从文本文件读取希伯来语

[英]Reading hebrew from text file with Java

I'm having troubles with reading a UTF-8 encoded text file in Hebrew. 我在希伯来语中读取UTF-8编码的文本文件时遇到麻烦。 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 谢谢,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. 您在使用InputStreamReader时未指定编码,因此它在平台上使用默认值-可能不是 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 . 请注意,为什么在这里使用DataInputStream并不明显...只需在FileInputStream周围创建一个InputStreamReader

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM