NetworkInterface isUp Example
NetworkInterface class isUp example. This example shows you how to use isUp method.
NetworkInterface class isUp example. public boolean isUp() throws SocketException Returns whether a network interface is up and running.
Here is the code
/*
* @ # Isup.java
* A class repersenting use to IsUp method
* of URL class in java.net package
* version 23 June 2008
* author Rose India
*/
import java.net.*;
public class IsUp {
public static void main(String args[]) throws Exception {
byte b[] = {127, 0, 0, 1};
InetAddress inetAddress = InetAddress.getByAddress(b);
NetworkInterface networkInterface =
NetworkInterface.getByInetAddress(inetAddress);
System.out.println("network interface is up and running "+
networkInterface.isUp());
}
} |
Output
| network interface is up and running true |
|