how to find out the end of the file in java

hi friends,

I am reading a file char by char. So how can I check for end of the file. I va a integer of the character and a string which has hex value of the character.

but when I execute the pgm, it shows out of memory error. overflow of the heap.

can anyone help?

thanks in advance...

bye

[328 byte] By [Shaik_Sajana] at [2007-11-26 23:51:04]
# 1
Read returns -1 when you have reached EOF.Kaj
kajbja at 2007-7-11 15:29:16 > top of Java-index,Java Essentials,New To Java...
# 2
> Read returns -1 when you have reached EOF.> > Kajhi Kaj,well it worked fine. thanks...now how can we know end of line?bye ,regards.
Shaik_Sajana at 2007-7-11 15:29:16 > top of Java-index,Java Essentials,New To Java...
# 3
Use a BufferedReader and readLine if you want to read lines. readLine will return null when there are no more lines.Kaj
kajbja at 2007-7-11 15:29:16 > top of Java-index,Java Essentials,New To Java...
# 4

> Use a BufferedReader and readLine if you want to read

> lines. readLine will return null when there are no

> more lines.

>

> Kaj

ya that i know. but i need to read each char and display each char in hex form. and wen the end of line happens it should go to the new line.

can we do that in java?

regards.

Shaik_Sajana at 2007-7-11 15:29:16 > top of Java-index,Java Essentials,New To Java...
# 5
Just read a line from the file. Iterate over all characters in the line, and print them, then read the next line. (So you should still use a BufferedReader or you are reading text, and BufferedInputStream if you are reading binary data)Kaj
kajbja at 2007-7-11 15:29:16 > top of Java-index,Java Essentials,New To Java...
# 6
Thanks friend. I got the output in required way. thanks once again. now how can v set the file type of a file?regards.
Shaik_Sajana at 2007-7-11 15:29:16 > top of Java-index,Java Essentials,New To Java...
# 7
There is no "type of file". It's all zeroes and ones.
CeciNEstPasUnProgrammeura at 2007-7-11 15:29:16 > top of Java-index,Java Essentials,New To Java...
# 8
> There is no "type of file". It's all zeroes and ones.thing is am wrintin a file. I want to set the type(extension) to be .iso. how can i do that?thanks in advance...
Shaik_Sajana at 2007-7-11 15:29:16 > top of Java-index,Java Essentials,New To Java...
# 9

> > There is no "type of file". It's all zeroes and

> ones.

>

> thing is am wrintin a file. I want to set the

> type(extension) to be .iso. how can i do that?

If you want to make the extension ".iso" then just end the file name with ".iso".

If you want to make the "type" iso, so that it can be manipulated by an iso application or whatever, then you have to make sure the bytes you write are of the proper format.

As already stated: Files don't have a type.

jverda at 2007-7-11 15:29:16 > top of Java-index,Java Essentials,New To Java...
# 10

> If you want to make the "type" iso, so that it can be

> manipulated by an iso application or whatever, then

> you have to make sure the bytes you write are of the

> proper format.

>

> As already stated: Files don't have a type.

thanks buddy...

a want to create an iso type. now let me try for it....

once again thnx...

bye.

regards.

Shaik_Sajana at 2007-7-11 15:29:16 > top of Java-index,Java Essentials,New To Java...