Java scripting develops specific geo-location information for IP based on customer IP

Source: Internet
Author: User
Tags get ip

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.