Original: Java script development to obtain IP-specific geo-location information based on customer IP
Source code: Http://www.zuidaima.com/share/1550463468522496.htm
Get IP addresses based on client IP
Operation Result:
Package Com.zuidaima.founder.util.ip;import Java.net.inetaddress;import java.net.unknownhostexception;/** * Function Description: Test * @author www.zuidaima.com */public class iptest{public static void Main (string[] args) {inetaddress addr = null;try {addr = Inetaddress.getlocalhost ();} catch (Unknownhostexception e) {e.printstacktrace ();} String ipstr = addr.gethostaddress (). ToString ();//Get native ipstring addressstr = Addr.gethostname (). ToString ();// Get the native name System.out.println ("Native IP address:" + ipstr + "native name:" + addressstr); String ipinfo = "120.197.41.37"; SYSTEM.OUT.PRINTLN ("IP address:" + ipinfo);//Specify the file name of the pure database, where the folder ipseeker IP = new Ipseeker (); System.out.println ("IP belongs to:" + ip.getiplocation (ipinfo). Getcountry () + "" + ip.getiplocation (ipinfo). Getarea ());}
Java scripting develops specific geo-location information for IP based on customer IP