从希伯来语文本文件java 8中读取

时间:2017-03-04 20:23:54

标签: java file io hebrew

我想用希伯来语读取文本文件,但我得到了一些犹太人......

这是我的代码:

try {
        workFile =new File("tripShosWork.txt");
        homeFile =new File("tripShosHome.txt");
        BufferedReader homeBr =  new BufferedReader(new FileReader(homeFile));
        BufferedReader workBr = new BufferedReader(new FileReader(workFile));
        home = new String [98];
        for (int i = 0; i < home.length; i++) 
            home[i] = homeBr.readLine();
        work = new String [19];
        for (int i = 0; i < work.length; i++) {
            work[i] = workBr.readLine(); 
        }
    } catch (Exception e) {
        e.printStackTrace();
    } 
    System.out.println(Arrays.toString(work));
    System.out.println(Arrays.toString(home));

我需要你的帮助!

1 个答案:

答案 0 :(得分:2)

你可以这样做:

FileInputStream fis = new FileInputStream("tripShosWork.txt");
InputStreamReader in = new InputStreamReader(fis, "Cp1255");

这假设该文件采用Windows希伯来语编码。使用"ISO8859_8"表示Latin-8。