[Logo]
Forums Register Login
neglecting an exception
hi,
plz help me from this.Is ther any solution to neglect an exception and to execute the rest in the try catch block.
 
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.
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());
}
}
}
-----------------------------------------------------
Maybe I'm missing something, but what's to stop you placing each connection attempt in its own try catch block?
 
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.
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
thanks i got it
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Nov 22, 2017 02:41:48.