色婷婷狠狠18禁久久YY,CHINESE性内射高清国产,国产女人18毛片水真多1,国产AV在线观看

java獲取linux

錢琪琛2年前27瀏覽0評論

java獲取linux?

代碼示例:

/**

* 獲取Linux下的IP地址

*

* @return IP地址

* @throws SocketException

*/

public static String getLinuxLocalIp() throws SocketException {

String ip = "";

try {

for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces();

en.hasMoreElements();) {

NetworkInterface intf = en.nextElement();

String name = intf.getName();

if (!name.contains("docker") && !name.contains("lo")) {

for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses();

enumIpAddr.hasMoreElements();) {

InetAddress inetAddress = enumIpAddr.nextElement();

if (!inetAddress.isLoopbackAddress()) {

String ipaddress = inetAddress.getHostAddress().toString();

if (!ipaddress.contains("::") && !ipaddress.contains("0:0:")

&& !ipaddress.contains("fe80")) {

ip = ipaddress;

}

}

}

}

}

} catch (SocketException ex) {

System.out.println("獲取ip地址異常");

ex.printStackTrace();

}

System.out.println("IP:" + ip);

return ip;

}

java獲取ip地址,java獲取linux