簡體   English   中英

了解 InetAddress

[英]Understanding InetAddress

我有這個代碼。它工作正常。但我不明白幾行代碼的含義。我在我無法理解的行旁邊寫了注釋。任何人都可以幫助我理解這些行。提前致謝:)

import java.net.InetAddress;

public class Netaddress
{
    public static void main(String a[]) throws Exception
      {
          InetAddress c;      //this line
          c =InetAddress.getLocalHost();   //and this one
          System.out.println("Local Address Is :"+c);
          System.out.println("Done!");
      }
}

InetAddress是 Java 中的一個類(java.net 包)。 來自getLocalHost的 javadoc(重點是我的

返回本地主機地址 這是通過從系統檢索主機的名稱,然后將該名稱解析為 InetAddress 來實現的。 注意:解析后的地址可能會被緩存一小段時間。

如果存在安全管理器,則使用本地主機名和 -1 作為參數調用其 checkConnect 方法,以查看是否允許操作。 如果不允許該操作,則返回表示環回地址的 InetAddress。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM