aspose file tools*
The moose likes Beginning Java and the fly likes Continueing after an Exception... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Continueing after an Exception..." Watch "Continueing after an Exception..." New topic
Author

Continueing after an Exception...

ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
I thought that there was a way to continue after a caught exception has been thrown.
I.E. I have a program that reads thru a list of machine names, then goes out and sends some UDP packtes to it. If the machine is turned off, or has been renamed, I will get an UnknownHostException.
What I want to know is, once I hit a bad machine, is there a way to go on thru the rest of the list rather than die right there.
Ryan Headley


Ryan Headley<br /><a href="http://www.sudovi.com" target="_blank" rel="nofollow">http://www.sudovi.com</a>
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4419
    
    5

How about putting your try/catch inside the list processing loop?
Junilu


Junilu - [How to Ask Questions] [How to Answer Questions]
ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
I thought about that, but the minute it hits the Exception, the program dies. Or at least it seems to.
However, the issue is a dead one now cause the problem was elsewhere...the name in the list was spelled wrong...heheh
Ryan
But now I am curious...I wonder if that would work...I am gonna hafta play with some code...
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

If you properly placed your try/catch block fully within the body of your loop, and it still seemed to die... perhaps you weren't catching the right exception? Sometimes it can throw more than one. If you catch (Exception e) < which is not recommended in 'real world' > Then you will know.
ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
Coming to think of it, I am sure that was the problem. I'll just move the for loop...
Thanx guys...
Like I said earlier, it was a different issue that fixed it, but its probably good practice/syntax to move that loop!
Thanx again
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Continueing after an Exception...
 
Similar Threads
Reset Hidden fields
How can I find out which ports are open?
how to retrieve parameters in the exact order?
is that possible fro a thread ???
Retrieving Cookies