• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help !!

 
Hema Sukumar
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is there anyway to check the end of file with the Buffered Reader ?
The traditional way of doing it as below,
------------------------------------------------------
String s;
while ( (s= br.readLine()) !=null)
-------------------------------------------------------
doesn't work for a text/html file which has some blank lines & then continuing with lines of data.
The method above breaks the loop as soon as it comes across an
empty line. Where as I want the loop to continue till it reads the whole file even it comes across some empty lines.
Any help will be highly appreciated.
Thanks,
Hema
 
Peter Tran
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hema,
Send me an example of your input file to ptran@javaranch.com.
-Peter
 
Hema Sukumar
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Peter,
I just sent a copy of my code to yr mail id.
-Hema
 
Peter Tran
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hema,
There wasn't much wrong with your program. You were closing your stream to early. You need to move the two close() statements outside your outer while() loop.

The output email.txt contains:

I'll let you clean up the email address.
Good luck.
-Peter
 
Hema Sukumar
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peter,
Thank you very much.
Sorry for bothering you with such silly mistake. Sometimes I tend to over look these little mistakes for Big bugs
Anyway, I'm still very much junior to java & learning a lot every day.
Cheers,
Hema
 
Peter Tran
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hema,
My pleasure. That's why we're all here to learn from each other. I've made much sillier mistakes. It's good that you know when to ask for help. Some people are too hard-headed and will look at a problem forever rather than asking for help.
-Peter
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!