minor formatting cleanup
This commit is contained in:
@@ -9,18 +9,18 @@ import com.maxmind.geoip2.DatabaseReader;
|
||||
import com.maxmind.geoip2.exception.GeoIp2Exception;
|
||||
import com.maxmind.geoip2.model.CityResponse;
|
||||
|
||||
public class RawDBDemoGeoIPLocationService{
|
||||
public class RawDBDemoGeoIPLocationService {
|
||||
private DatabaseReader dbReader;
|
||||
|
||||
|
||||
public RawDBDemoGeoIPLocationService() throws IOException {
|
||||
File database = new File("your-path-to-db-file");
|
||||
dbReader = new DatabaseReader.Builder(database).build();
|
||||
}
|
||||
|
||||
|
||||
public GeoIP getLocation(String ip) throws IOException, GeoIp2Exception {
|
||||
InetAddress ipAddress = InetAddress.getByName(ip);
|
||||
CityResponse response = dbReader.city(ipAddress);
|
||||
|
||||
|
||||
String cityName = response.getCity().getName();
|
||||
String latitude = response.getLocation().getLatitude().toString();
|
||||
String longitude = response.getLocation().getLongitude().toString();
|
||||
|
||||
Reference in New Issue
Block a user