1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > java 多网卡ip_java获取双网卡ip地址

java 多网卡ip_java获取双网卡ip地址

时间:2021-06-27 21:08:59

相关推荐

java 多网卡ip_java获取双网卡ip地址

package com.et59.License;

import .InterfaceAddress;

import workInterface;

import .SocketException;

import java.util.Collections;

import java.util.Enumeration;

import java.util.List;

/**

*

*

Title: ListNets.java

*

Description: 获取双网卡ip

*

Copyright: 59et Software (c)

*

Company: 点滴工作室

* @author Liuhh(jxausea@)

* @date -7-18 下午03:52:03

* @version 2.0

*

*/

public class ListNets {

public static void main(String args[]) throws SocketException {

Enumeration nets = NetworkInterface

.getNetworkInterfaces();

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

if (null != netint.getHardwareAddress()) {

List list = netint.getInterfaceAddresses();

for (InterfaceAddress interfaceAddress : list) {

String localip=interfaceAddress.getAddress().toString();

System.out.println(localip);

}

}

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。