zoukankan      html  css  js  c++  java
  • 获取 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);
  • 相关阅读:
    图书-哲学-奥卡姆剃刀:《奥卡姆剃刀原理》
    汉语-词语-认知:认知能力
    汉语-词语-认知:认知水平
    汉语-词语:认知
    pg_dump
    pg_ctl
    pg_controldata
    pg_config
    paste
    passwd
  • 原文地址:https://www.cnblogs.com/lxh520/p/7990500.html
Copyright © 2011-2022 走看看