![](/img/trans.png)
[英]How can I get phone area code from MaxMind's GeoLite2 City local mmdb and associated Java API?
[英]Query by city name on geolite2 .mmdb file (JAVA)
我正在使用GeoLite2來獲取我的java應用程序的IP地址。
我想從GeoLite2-City.mmdb文件獲取城市。
這是我的讀者:
DatabaseReader reader = new DatabaseReader.Builder(dbFileStream).withCache(new CHMCache()).build();
我通過以下IP地址獲取CityResponse:
CityResponse cityResponse = reader.city(InetAddress.getByName("an IP address"));
但我希望按城市獲取國家名稱:
String countryName = reader.getCountryByCity("Paris”);
有沒有辦法做到這一點?
這是不可能的。 該數據庫旨在通過IP地址進行查找。 如果您需要以其他方式訪問數據,我建議使用MaxMind提供的CSV文件。
此外,您可以嘗試項目geonames.org 及其java-api庫
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.