GithubHelp home page GithubHelp logo

runt18 / java-db-ip Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ankushs92/java-db-ip

0.0 2.0 0.0 33 KB

A Java wrapper for DB-IP free city database

License: MIT License

Java 77.37% Groovy 22.63%

java-db-ip's Introduction

Java DB-IP

A simple to use Java library for the freely available DB-IP IP address to city dataset. Requires Java 8

#Before you begin The entire dataset is loaded into a TreeMap . Make sure that you have about 3 GB of Heap space available to load it.

#Get

With maven :

<dependency>
	  <groupId>in.ankushs</groupId>
	  <artifactId>Java-DB-IP</artifactId>
	  <version>1.0</version>
</dependency>

Or gradle:

compile('in.ankushs:Java-DB-IP:1.0')

The Javadocs for the latest release can be found here

#Instructions In order to get geographical information for an ip address, just pass the dbip-city-latest.csv.gz as a File object to DbIpClient as follows:

File gzip = new File(PATH_TO_dbip-city-latest.csv.gz);
DbIpClient client = new DbIpClient(gzip);

Once the data is loaded from the file into memory , any subsequent invocation of the above code would not re-load the data .

Next,just fetch the data for a ip ,like so :

DbIpClient client = new DbIpClient(gzip);
GeoEntity geoEntity = client.lookup("31.45.127.255");
String city = geoEntity.getCity();
String country = geoEntity.getCountry();
String province = geoEntity.getProvince();

System.out.println("city : " + city);
System.out.println("province : " + province);
System.out.println("country : " + country);

This prints :

city : Oslo
province : Oslo
country : Norway

That's pretty much it.

#Integrating with Spring Boot. Follow the detailed instructions on this blogpost . You can find the Spring Boot Java-DB-IP project here .

Bitdeli Badge

java-db-ip's People

Contributors

ankushs92 avatar bitdeli-chef avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.