㈠ java 如何获取连接网络连接信息
importjava.io.IOException;importjava.net.InetAddress;publicclassInetAddressTest{publicstaticvoidmain(String[]args)throwsIOException{InetAddressaddr=InetAddress.getLocalHost();//获取本机ipSystem.out.println("localhost:"+addr);//获取指定服务的一个主机IPaddr=InetAddress.getByName("google.com");System.out.println("google:"+addr);//获取指定服务的所有主机IPInetAddress[]addrs=InetAddress.getAllByName("google.com");for(inti=0;i<addrs.length;i++)System.out.println("google:"+addrs[i]+"number:"+i);//获取远程主机可达性System.out.println(InetAddress.getByName("localhost").isReachable(1000));}}