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);
}
posted on 2006-10-11 17:23
无声 阅读(526)
评论(0) 编辑 收藏 所属分类:
java共享代码