NetWork interface Reader
import java.io.*;
import java.net.*;
import java.util.*;
import static java.lang.System.out;
public class Main {
public void call()
{
}
public static void main(String[] args) throws IOException {
Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
int i=0;
for (NetworkInterface netint : Collections.list(nets))
{out.print("---------------------"+i+++"\n");
displayInterfaceInformation(netint);
}
}
static void displayInterfaceInformation(NetworkInterface netint) throws SocketException {
out.printf("Display name: %s\n", netint.getDisplayName());
out.printf("Name: %s\n", netint.getName());
Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
for (InetAddress inetAddress : Collections.list(inetAddresses)) {
out.printf("InetAddress: %s\n", inetAddress);
}
out.printf("Up? %s\n", netint.isUp());
out.printf("Loopback? %s\n", netint.isLoopback());
out.printf("PointToPoint? %s\n", netint.isPointToPoint());
out.printf("Supports multicast? %s\n", netint.supportsMulticast());
out.printf("Virtual? %s\n", netint.isVirtual());
out.printf("Hardware address: %s\n",
Arrays.toString(netint.getHardwareAddress()));
out.printf("MTU: %s\n", netint.getMTU());
out.printf("\n");
}
}
No comments:
Post a Comment