• Post Reply Bookmark Topic Watch Topic
  • New Topic

Handling FileNotFoundException

 
Kaushal Sinha
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have a java program which will read a file containing email addresses from a file and also a unique number from the same file . I have to send an email to each email address with a file attachment , the name of the file is derived using ths unique number in the address file. The problem I am having is when the file does not exist for a particular person. What I really want to do is not send the email to the person , for whom the file does not exists , but still continue to send email to others who do have a file corresponding to their numbers.
Here is teh code I am using to do this..

Thanks.
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just move the catch block for FileNotFoundException inside the while loop and when one of such occurs just discard it with, for instance, a continue statement and proceed to the next file
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!