如何模拟花生壳软件功能, 取得 adsl 联接 internet 的出口 IP 呢? 在启动花生壳软件时, 看到界面上可以显示 adsl 的出口 IP 地址, 如何模拟花生壳这个功能, 取得 adsl 联接 internet 的出口 IP 呢? 用 Java 可以实现这个功能吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 InetAddress[] all=InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());InetAddress local=InetAddress.getLocalHost();//在all中.不等于local的就是. 上网方式是通过 network card -> switch -> router -> adsl modem -> internet照上面方式得到的结果是本地 IP 地址如下: all: 192.168.1.3all: win0001localhost: 192.168.1.3localhost: win0001如何才能得到 adsl IP 呢? import java.net.*;class GetADSLIP{ public static void main(String args[]) throws Exception { InetAddress[] all=InetAddress.getAllByName(InetAddress.getLocalHost().getHostName()); InetAddress local=InetAddress.getLocalHost(); for(int i=0;i<all.length;i++) { if(local.equals(all[i])) continue; System.out.println(all[i].getHostAddress()); } }} List的removeAll方法异常? 作用域和可见性的问题,求解释!! 找错!送分,今天无意中发现的错误。 TCP/IP问题 小问题 java回收内存的方法 高分求解几个问题。非常急!!! JTabel内容覆盖问题 想写一个检查一个文件是不是抄袭另一个文件的程序 有大神知道吗? JAVA为何把汉字变成了3个字节? 关于二进制文件生成的问题? 新手求教:关于输入数字,用起泡法排序的问题
InetAddress local=InetAddress.getLocalHost();
//在all中.不等于local的就是.
上网方式是通过 network card -> switch -> router -> adsl modem -> internet
照上面方式得到的结果是本地 IP 地址如下: all: 192.168.1.3
all: win0001
localhost: 192.168.1.3
localhost: win0001
如何才能得到 adsl IP 呢?
class GetADSLIP
{
public static void main(String args[]) throws Exception
{
InetAddress[] all=InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());
InetAddress local=InetAddress.getLocalHost();
for(int i=0;i<all.length;i++)
{
if(local.equals(all[i]))
continue;
System.out.println(all[i].getHostAddress());
}
}
}