欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
用java得到本機所有的ip地址
轉載聲明:版權規文章原創(chuàng )作者所有
轉載時(shí)間:2007年07月17日
轉載作者:pablo3518

用java得到本機所有的ip地址
 
package com.sourceware.util;

import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.HttpClient;
import org.apache.log4j.Logger;
import java.net.InetAddress;
import java.util.Enumeration;
import java.net.NetworkInterface;
import java.util.*;

/**
 *
 * <p>Title: Sourceware utils.</p>
 *
 * <p>Description: Sourceware utils.</p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company: Sourceware inc.</p>
 *
 * @author 黑山(woowind@sina.com)
 * @version 1.0
 */
public class NetUtil {

  static Logger logger = Logger.getLogger(NetUtil.class);

  public NetUtil() {
  }

  /**
   *
   * @param url String
   * @return int
   * @throws Exception
   */
  public static int clickURL(String url) throws Exception {
    int retrycount = 3;
    while (true) {
      HttpClient httpClient = new HttpClient();
      GetMethod get = new GetMethod(url);
      get.addRequestHeader("Content-Type", "text/html; charset=GBK");
      int code = httpClient.executeMethod(get);
      if (code != 200) {
        if (retrycount == 0) {
          throw new Exception("發(fā)送失敗,失敗原因=" + code);
        }
        logger.error("send to[" + url + "]error code[" + code + "]");
        retrycount--;
      }
      else {
        return code;
      }

    } //end while(true)...
  }

  /**
   *
   * @return Collection
   */
  public static Collection getAllLocalIP() throws Exception {
    ArrayList ar = new ArrayList();
    Enumeration netInterfaces = NetworkInterface.getNetworkInterfaces();
    while (netInterfaces.hasMoreElements()) {
      NetworkInterface ni = (NetworkInterface) netInterfaces.nextElement();
      InetAddress ip = (InetAddress) ni.getInetAddresses().nextElement();
      if (!ip.isSiteLocalAddress() && !ip.isLoopbackAddress() &&
          ip.getHostAddress().indexOf(":") == -1) {
        System.out.println("Interface " + ni.getName() +
                           " seems to be InternetInterface. I‘ll take it..."); ;
      }
      else {
        ar.add(ip.getHostAddress());
      }
    }
    return ar;
  }

  public static void main(String[] args) {
    try {
      NetUtil.getAllLocalIP();
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
  }
}

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
Java 如果獲取本機信息 如本機操作系統 IP MAC... - Java / Java...
Android獲取本機Mac地址及IP地址方法
直接上一段用于內網(wǎng)獲取本機ip地址的方法,更全面的可以先獲取本機網(wǎng)絡(luò )類(lèi)型,在獲取ip
Java 獲取手機/平板IP地址的方法
java 網(wǎng)絡(luò )編程 -- IP地址的表示與網(wǎng)絡(luò )接口信息的獲?。↖netAddress和NetworkInterface)
用java獲取本機IP地址
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久