0

I'm tring to read from text file in hebrew but i get some jebrish...

this is my code:

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));

i need your help!

Yos
  • 41
  • 1
  • 6

1 Answers1

3

You can do it like this:

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

This assumes that the file is in the Windows Hebrew encoding. Use "ISO8859_8" for Latin-8.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263