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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "neglecting an exception" Watch "neglecting an exception" New topic
Author

neglecting an exception

feroz muhamed
Ranch Hand

Joined: Nov 15, 2003
Posts: 87
hi,
plz help me from this.Is ther any solution to neglect an exception and to execute the rest in the try catch block.
Vicken Karaoghlanian
Ranch Hand

Joined: Jul 21, 2003
Posts: 522
Originally posted by feroz muhamed:
hi,
plz help me from this.Is ther any solution to neglect an exception and to execute the rest in the try catch block.

Hi Feroz, What do you mean by neglect??!! if the exception is checked then you MUST catch it with a try-catch block.


- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. - What truth? - That there is no spoon!!!
feroz muhamed
Ranch Hand

Joined: Nov 15, 2003
Posts: 87
I 've given the code below.here if the first machine abc is down exception rises and terminates without getting the name of second system which is running.but i need the second either the first is on or off.please help.
code
------------------------------------------------------
import java.net.*;
class forv{
public static void main(String a[])
{
try{
InetAddress i=InetAddress.getByName("abc");
InetAddress i1=InetAddress.getByName("arf");
}catch(UnknownHostException u){
System.out.println("no host "+u.getMessage());
}
}
}
-----------------------------------------------------
Ben Poole
Ranch Hand

Joined: Jul 17, 2003
Posts: 33
Maybe I'm missing something, but what's to stop you placing each connection attempt in its own try catch block?
Vicken Karaoghlanian
Ranch Hand

Joined: Jul 21, 2003
Posts: 522
Originally posted by feroz muhamed:
I 've given the code below.here if the first machine abc is down exception rises and terminates without getting the name of second system which is running.but i need the second either the first is on or off.please help.
code
------------------------------------------------------
import java.net.*;
class forv{
public static void main(String a[])
{
try{
InetAddress i=InetAddress.getByName("abc");
InetAddress i1=InetAddress.getByName("arf");
}catch(UnknownHostException u){
System.out.println("no host "+u.getMessage());
}
}
}
-----------------------------------------------------

Then why don't you do what Ben suggested (place each machine in a different try-catch block). It will work that way.
feroz muhamed
Ranch Hand

Joined: Nov 15, 2003
Posts: 87
hi thanks it worked well but the problem is that i am getting the system names using 'net view ' command so i want to do this dynamically(i mean calling getByName("//dynamically changing ")).so making each in separate try catch block is something difficult.plz help if any other soln
feroz muhamed
Ranch Hand

Joined: Nov 15, 2003
Posts: 87
thanks i got it
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: neglecting an exception