<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # Java 程序:獲取 IP 地址 > 原文: [https://beginnersbook.com/2014/07/java-program-to-get-ip-address/](https://beginnersbook.com/2014/07/java-program-to-get-ip-address/) 在這個例子中,我們將看到如何獲得系統的 IP 地址。步驟如下: 1)通過調用`InetAddress`類的`getLocalHost()`方法獲取本地主機地址。 2)通過調用`getHostAddress()`方法獲取 IP 地址。 ```java import java.net.InetAddress; class GetMyIPAddress { public static void main(String args[]) throws Exception { /* public static InetAddress getLocalHost() * throws UnknownHostException: Returns the address * of the local host. This is achieved by retrieving * the name of the host from the system, then resolving * that name into an InetAddress. Note: The resolved * address may be cached for a short period of time. */ InetAddress myIP=InetAddress.getLocalHost(); /* public String getHostAddress(): Returns the IP * address string in textual presentation. */ System.out.println("My IP Address is:"); System.out.println(myIP.getHostAddress()); } } ``` **輸出:** ```java My IP Address is: 115.242.7.243 ``` **參考:** [`InetAddress` javadoc](https://docs.oracle.com/javase/7/docs/api/java/net/InetAddress.html)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看