import com.ip2location.*; import java.io.File; import java.io.IOException; import java.util.Scanner; import java.util.ArrayList; import java.util.List; public class Main { public Main() { } { /* * Steps: * 1.Copy the Main.java from the "demos" folder * 2.Configure Build Path by import external jars file which can be found in the "libs" folder * 3.Create/copy "IPAddress.txt" into the project workspace * 4.Edit the IP Address in the text file * 5.Define the BinFilePath in line 73 */ try{ //Read IP addresses into array from the textFile List<String> lines = new ArrayList<String>(); while(sc.hasNextLine()){ lines.add(sc.nextLine()); } try { //Define the path of the file here // Example : String BinFilePath = "C:/Users/xxx/Desktop/ip2locationjavacomponent/demos/IP2LOCATION-LITE-DB1.BIN"; //Define the IP Address you want to test IP2Location loc = new IP2Location(); if (args.length == 2 || args.length == 3) { loc.IPDatabasePath = args[0]; if (args.length == 3) { loc.IPLicensePath = args[2]; } IPResult rec = loc.IPQuery(args[1]); if ("OK".equals(rec.getStatus())) { } else if ("EMPTY_IP_ADDRESS".equals(rec.getStatus())) { } else if ("INVALID_IP_ADDRESS".equals(rec.getStatus())) { } else if ("MISSING_FILE".equals(rec.getStatus())) { } else if ("IPV6_NOT_SUPPORTED".equals(rec.getStatus())) { } else { } if (rec.getDelay() == true) { } } else { } } { } } } } } }