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");
}
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");
}
相关文章推荐
- weka[1]-导入eclipse并加载数据集
- Spring学习基础知识
- 米老师讲课 ITOO4.1 ——Java(2)
- JAVA中常见的Exception
- 异常管理 - try-catch-finally异常信息丢失
- javase--day_01
- javase--day_01
- java 获取绝对路径去除路径的%空格问题
- Struts2 常用常量配置
- java 内部类(第二讲 staitc)
- Spring Mvc学习笔记(一)续
- 米老师讲 ITOO4.1 ——Java
- Java实现HTML转PDF的总结
- java 多线程的实现
- Java知识二:泛型
- JAVA HashMap详细介绍和示例
- Java连接MySQL
- Spring 69题
- SpringSecurity3.1入门教程(四)
- Eclipse构建Maven项目