获取网卡信息
import java.net.*;
//...
System.out.println("/n+---------------------[ Network Cards ]----------------------+/n");
try{for(Enumeration list = NetworkInterface.getNetworkInterfaces(); list.hasMoreElements();)
{
NetworkInterface iFace = (NetworkInterface)list.nextElement();
System.out.println("Card:" + iFace.getDisplayName());
InetAddress adr;
for(Enumeration addresses = iFace.getInetAddresses(); addresses.hasMoreElements(); System.out.println(" -> " + adr.getHostAddress()))
adr = (InetAddress)addresses.nextElement();
}
}catch(SocketException se)
{
System.out.println("Failed discovering network cards!");
System.out.println("Error: " + se);
}
import java.net.*;
//...
System.out.println("/n+---------------------[ Network Cards ]----------------------+/n");
try{for(Enumeration list = NetworkInterface.getNetworkInterfaces(); list.hasMoreElements();)
{
NetworkInterface iFace = (NetworkInterface)list.nextElement();
System.out.println("Card:" + iFace.getDisplayName());
InetAddress adr;
for(Enumeration addresses = iFace.getInetAddresses(); addresses.hasMoreElements(); System.out.println(" -> " + adr.getHostAddress()))
adr = (InetAddress)addresses.nextElement();
}
}catch(SocketException se)
{
System.out.println("Failed discovering network cards!");
System.out.println("Error: " + se);
}