© 1999-2048 dssz.net 粤ICP备11031372号
package org.lc.util; import java.io.IOException; public class Web { public static void main(String args[]){ System.out.println(getAddr ByIP("127.0.0.1")); } public static String getAddrByIP(String ip) throws IOException{ java.net.URL server; String str=""; server=new java.net.URL("http://www.ip.cn/getip.php?action=queryip&ip_url="+ip); java.net.URLConnection con=server.openConnection(); java.io.InputStream in=con.getInputStream(); int c; while((c=in.read())!=-1){ str+=((char)c); } str=new String(str.getBytes("ISO8859-1")); return str.substring(str.indexOf("来自:")+"来自:".length()); } }...展开收缩