/
NetspeedLookupTest.java
32 lines (29 loc) · 1.03 KB
/
NetspeedLookupTest.java
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
/* NetspeedLookup.java */
import com.maxmind.geoip.*;
import java.io.IOException;
/* sample of how to use the GeoIP Java API with GeoIP Netspeed database */
/* Usage: java NetspeedLookupTest 24.24.24.24 */
class NetspeedLookupTest {
public static void main(String[] args) {
try {
LookupService cl = new LookupService("/usr/local/share/GeoIP/GeoIPNetspeed.dat");
if (args.length > 0) {
int speed = cl.getID(args[0]);
if (speed == cl.GEOIP_UNKNOWN_SPEED){
System.out.println("Unknown");
} else if (speed == cl.GEOIP_DIALUP_SPEED) {
System.out.println("Dialup");
} else if (speed == cl.GEOIP_CABLEDSL_SPEED) {
System.out.println("Cable/DSL");
} else if (speed == cl.GEOIP_CORPORATE_SPEED) {
System.out.println("Corporate");
}
} else {
System.out.println("input a ip address\n");
}
}
catch (IOException e) {
System.out.println("IO Exception");
}
}
}