1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| import java.net.InetAddress;
public class Test
{
public static void main(String[] arigs)
{
try
{
final String hostName = "www.google.fr";
final InetAddress target = InetAddress.getByName(hostName);
if(target!=null)
{
final boolean ping = target.isReachable(1000);
System.out.println(ping?"target reached":"unable to reach the target");
}
else System.out.println("false target");
}
catch(Exception e)
{
System.err.println("Pas cool! Erreur : "+e);
e.printStackTrace();
System.exit(0);
}
}
} |