您的位置:首页 > 编程语言 > Java开发

java获取本地网卡信息

2015-12-23 15:48 399 查看
public static void main(String args[]) throws SocketException {

Enumeration<NetworkInterface> nets = NetworkInterface

.getNetworkInterfaces();

for (NetworkInterface netint : Collections.list(nets))

displayInterfaceInformation(netint);

}

static void displayInterfaceInformation(NetworkInterface netint)

throws SocketException {

System.out.printf("Display name: %s\n", netint.getDisplayName());

System.out.printf("Name: %s\n", netint.getName());

Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();

for (InetAddress inetAddress : Collections.list(inetAddresses)) {

System.out.printf("InetAddress: %s\n", inetAddress);

}

System.out.printf("\n");

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: