chen0040 / java-geoip

A simple library for converting ip address to country

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

java-geoip

A simple library for converting ip address to country

Install

Add the following dependency to your POM file:

<dependency>
  <groupId>com.github.chen0040</groupId>
  <artifactId>java-geoip</artifactId>
  <version>1.0.1</version>
</dependency>

Usage

The sample codes below shows how to use the GeoIp class in your application:

import com.github.chen0040.geoip.GeoIp;

public class Demo {
    public static void main(String[] args) {
        GeoIp geoIp = new GeoIp();
        final String ipAddress = "13.93.122.38";
        CountryResponse country = geoIp.getCountry(ipAddress);
        System.out.pritnln("Country from which ip " + ipAddress + " comes from is " + country.getCountry().getName());
    }
}

About

A simple library for converting ip address to country

License:MIT License


Languages

Language:Java 100.0%