Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Language problem when reading from a file

Status
Not open for further replies.

thelordoftherings

Programmer
May 16, 2004
616
IL
Hello,

I have a text file which contains data in Hebrew.
I am using these lines in order to read from the file:

File inputFile = new File("C:\\test.txt");
BufferedReader input = new BufferedReader (new FileReader (inputFile));
while ((line = input.readLine()) != null)
....

The problem is that when I print what I read I receive "Gibrish" letters which is impossible to read, it looks like the collection of the data doesn't keep the language. Is there any way to solve this? perhaps converting the String to a unicode in some way?

Roy
 
What charset are you using ? And what charset is Hebrew ?

--------------------------------------------------
Free Database Connection Pooling Software
 
Hey sedj,

I don't know which charset I am using but I do know that Hebrew is at charset ISO-8859-8.
 
Your probably using the English charset ISO-8859-1 - which is obviously different to the Hebrew charset - which I guess is why you are seeing problems. I'm not sure if you can use two different charsets in an OS, let alone a JVM ...

--------------------------------------------------
Free Database Connection Pooling Software
 
So what you mean is that the JVM takes the default charset from the OS? In any case, isn't there a Java method which takes a char and returns it's Unicode representation? This way I am sure my problem will be solved.
 
Well you can change the charset of the JVM, but I'm not sure how - try googling.

As for your unicode representation, I'm not so sure ... if you can then great, but I'm not sure how you do ...

--------------------------------------------------
Free Database Connection Pooling Software
 
Hey sedj,

Just for u to know, I was able to solve it: One of the String constructors receives bytesarray and a Strin which represents a charset. When entering the source String as byte array and writing "ISO-8859-8" at the charset it solves the proble. As simple as that! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top