• 获取 ip 地址


    1. StringBuilder IFCONFIG=new StringBuilder();  
    2.    try {  
    3.        for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {  
    4.            NetworkInterface intf = en.nextElement();  
    5.            for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {  
    6.                InetAddress inetAddress = enumIpAddr.nextElement();  
    7.                if (!inetAddress.isLoopbackAddress() && !inetAddress.isLinkLocalAddress() && inetAddress.isSiteLocalAddress()) {  
    8.                IFCONFIG.append(inetAddress.getHostAddress().toString()+" ");  
    9.                }  
    10.   
    11.            }  
    12.        }  
    13.    } catch (SocketException ex) {  
    14.    }  
    15.    System.out.println(IFCONFIG);
  • 相关阅读:
    常用的正则表达式
    Nginx反向代理
    docker-day1-安装和基本使用
    Nginx + Keepalived
    Nginx源码安装
    apache-实战(二)
    apache-实战(一)
    apache--配置文件属性介绍
    软件目录结构规范
    python常用模块(二)
  • 原文地址:https://www.cnblogs.com/lxh520/p/7990500.html
Copyright © 2020-2023  润新知