可能重複:
how to get users ip address in java
Get IP address with URL string? (Java)如何獲得IP添加在JAVA像下面的鏈接
鏈接:
"http://automation.whatismyip.com/n09230945.asp"
上面的鏈接返回外部IP 。
我儘量讓自己的代碼,讓我的IP像上面的鏈接
我的代碼是
字符串my_own_ip = InetAddress.getLocalHost()getHostAddress()。
因此如何得到這個IP
在此代碼返回我的內部IP
我在LAN連接我的局域網IP是192.168.0.109
和外部的IP是27.54.180.156
I want 27.54.180.156
由於提前
您對問題http:// stackoverflow的回答。com/questions/9286861/get-ip-address-with-url-string-java – Smit
你試過'InetAddress.getByName(「www.external-name-of-your-host.com」)嗎? – dasblinkenlight
我想要我的IP地址 –