java 如何使用 MaxMind 的 GeoIP 数据库来确定位置?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14746169/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I use MaxMind's GeoIP database to determine location?
提问by Little Child
So, I was told in my previous question that I can use the databases provided by MaxMindto determine locations.
所以,我在上一个问题中被告知我可以使用MaxMind 提供的数据库来确定位置。
So, I got their databases downloaded from their site. They are csv
files and open up in Excel.
所以,我从他们的网站下载了他们的数据库。它们是csv
文件并在 Excel 中打开。
InetAddress ip = InetAddress.getLocalHost()
is how I get the IP of my computer. From there I do String justIP = ip.getHostAddress()
InetAddress ip = InetAddress.getLocalHost()
是我如何获得我的电脑的IP。从那里我做String justIP = ip.getHostAddress()
My question is:
我的问题是:
justIP
to a city location using the DB I just downloaded ??? justIP
使用我刚下载的数据库解析到城市位置???我对此很陌生,因此将不胜感激。
One of the files has three columns. startIPNum
, endIPNum
and locID
I do not know what these do but I guess locID
maps to a city and country location in the other file.
其中一个文件具有三列。startIPNum
,endIPNum
而locID
我不知道这些做的,但我想locID
映射到另一个文件中的城市和国家的位置。
回答by Fusselchen
Did you tried the Java examples from Maxmind? http://dev.maxmind.com/geoip/downloadable#Java-8
And see http://dev.maxmind.com/geoip/csvfor field descriptions
您是否尝试过 Maxmind 的 Java 示例?http://dev.maxmind.com/geoip/downloadable#Java-8有关字段说明
,请参阅http://dev.maxmind.com/geoip/csv