<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Dedian  
    -- 關注搜索引擎的開發
    日歷
    <2006年8月>
    303112345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789
    統計
    • 隨筆 - 82
    • 文章 - 2
    • 評論 - 228
    • 引用 - 0

    導航

    常用鏈接

    留言簿(8)

    隨筆分類(45)

    隨筆檔案(82)

    文章檔案(2)

    Java Spaces

    搜索

    •  

    積分與排名

    • 積分 - 66098
    • 排名 - 813

    最新評論

    閱讀排行榜

    評論排行榜

     

    1. Getting the IP Address of a Hostname

        try 
    {
    InetAddress addr = InetAddress.getByName("yahoo.com");
    byte[] ipAddr = addr.getAddress();

    // Convert to dot representation
    String ipAddrStr = "";
    for (int i=0; i<ipAddr.length; i++) {
    if (i > 0) {
    ipAddrStr += ".";
    }
    ipAddrStr += ipAddr[i]&0xFF;
    }
    }
    catch (UnknownHostException e) {
    }


    2. Getting the Hostname of an IP Address

    This example attempts to retrieve the hostname for an IP address. Note that getHostName() may not succeed, in which case it simply returns the IP address.

    try {
    // Get hostname by textual representation of IP address
    InetAddress addr = InetAddress.getByName("127.0.0.1");

    // Get hostname by a byte array containing the IP address
    byte[] ipAddr = new byte[]{127, 0, 0, 1};
    addr = InetAddress.getByAddress(ipAddr);

    // Get the host name
    String hostname = addr.getHostName();

    // Get canonical host name
    String hostnameCanonical = addr.getCanonicalHostName();
    } catch (UnknownHostException e) {
    }

    3. Getting the IP Address and Hostname of the Local Machine

        try {
    InetAddress addr = InetAddress.getLocalHost();

    // Get IP Address
    byte[] ipAddr = addr.getAddress();

    // Get hostname
    String hostname = addr.getHostName();
    } catch (UnknownHostException e) {
    }

    posted on 2006-08-18 06:53 Dedian 閱讀(563) 評論(0)  編輯  收藏 所屬分類: Java Memo
     
    Copyright © Dedian Powered by: 博客園 模板提供:滬江博客
    主站蜘蛛池模板: 相泽亚洲一区中文字幕| 午夜视频免费成人| 久久久久国产免费| 四虎国产精品永久免费网址 | 国产成人免费在线| 免费无码国产V片在线观看| 日韩在线视频播放免费视频完整版| 大妹子影视剧在线观看全集免费| 最近新韩国日本免费观看| 国产精品免费视频一区| 亚洲αv在线精品糸列| 亚洲乱码无限2021芒果| 亚洲6080yy久久无码产自国产| 久久九九久精品国产免费直播| 国产无人区码卡二卡三卡免费 | 免费**毛片在线播放直播| 亚洲成熟xxxxx电影| 亚洲AV香蕉一区区二区三区| 日本高清免费不卡视频| 亚洲国产av美女网站| 成人免费午夜在线观看| 亚洲av鲁丝一区二区三区| 91在线手机精品免费观看| 亚洲中文字幕无码爆乳app| 精品国产麻豆免费人成网站| 国产女高清在线看免费观看| 曰韩无码AV片免费播放不卡| 亚洲AV综合色区无码一区爱AV | 美女视频黄a视频全免费网站色窝| 亚洲国产成人久久综合一| 国产亚洲日韩在线a不卡| 国内精自视频品线六区免费| 亚洲精品伦理熟女国产一区二区| 100部毛片免费全部播放完整| 国产精品亚洲综合| 免费观看国产小粉嫩喷水| 国产亚洲福利在线视频| 香蕉免费一区二区三区| 亚洲天堂免费在线| 在线看片免费不卡人成视频| 久久国产亚洲精品无码|