随笔-200  评论-148  文章-15  trackbacks-0
				
						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 无声 阅读(525) 评论(0)  编辑  收藏 所属分类: java共享代码

只有注册用户登录后才能发表评论。


网站导航: