-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCityLookupTestV6.java
More file actions
36 lines (32 loc) · 1.46 KB
/
CityLookupTestV6.java
File metadata and controls
36 lines (32 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* CityLookupTest.java */
import com.maxmind.geoip.*;
import java.io.IOException;
/* sample of how to use the GeoIP Java API with GeoIP City database */
/* Usage: java CityLookupTest 64.4.4.4 */
class CityLookupTestV6 {
public static void main(String[] args) {
try {
LookupService cl = new LookupService("/usr/local/share/GeoIP/GeoLiteCityv6.dat",
LookupService.GEOIP_MEMORY_CACHE );
Location l1 = cl.getLocationV6("::213.52.50.8");
Location l2 = cl.getLocationV6(args[0]);
System.out.println("countryCode: " + l2.countryCode +
"\n countryName: " + l2.countryName +
"\n region: " + l2.region +
"\n regionName: " + regionName.regionNameByCode(l2.countryCode, l2.region) +
"\n city: " + l2.city +
"\n postalCode: " + l2.postalCode +
"\n latitude: " + l2.latitude +
"\n longitude: " + l2.longitude +
"\n distance: " + l2.distance(l1) +
"\n distance: " + l1.distance(l2) +
"\n metro code: " + l2.metro_code +
"\n area code: " + l2.area_code +
"\n timezone: " + timeZone.timeZoneByCountryAndRegion(l2.countryCode, l2.region));
cl.close();
}
catch (IOException e) {
System.out.println("IO Exception");
}
}
}