㈠ 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));}}