Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Help finding EOF

  Asked By: Maria    Date: Dec 26    Category: Java    Views: 852
  

I am trying to know the number of lines in a text file . And want to
know if there is a EOF('\0') character with which i can compare and
find the number of lines in the text file by looping .

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Oscar Evans     Answered On: Dec 26

EOF is not END OF FILE. its a character. it is not a true EOF. conside
the program you are writing to test for EOF. it must contain a
character of value 0 before the end of the file!

what you want is to know the file  size.

which loop counter != file size
read file
if content = 13 || content = 11 (line feed characters)
...
end if
loop

get the file size using the File object
compare characters using (String)s.charAt(int)

 
Didn't find what you were looking for? Find more on Help finding EOF Or get search suggestion and latest updates.




Tagged: