File tree Expand file tree Collapse file tree 5 files changed +14
-5
lines changed
Expand file tree Collapse file tree 5 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ Below are the methods supported in this class.
3333| ---| ---|
3434| Open(String DBPath, boolean UseMMF)| Initialize the component and preload the BIN file.|
3535| Open(String DBPath)| Initialize the component and preload the BIN file.|
36+ | Open(byte[ ] db)| Initialize the component with the byte array containing the BIN file data.|
3637| IPQuery(String IPAddress)| Query IP address. This method returns results in com.ip2location.IPResult object.|
3738| Close()| Destroys the mapped bytes.|
3839
@@ -80,6 +81,7 @@ Below are the status codes.
8081
8182``` java
8283import com.ip2location.* ;
84+ // import java.nio.file.*;
8385
8486public class Main
8587{
@@ -94,8 +96,15 @@ public class Main
9496 String binfile = " /usr/data/IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE-ADDRESSTYPE-CATEGORY.BIN" ;
9597
9698 IP2Location loc = new IP2Location ();
99+
100+ // this is to initialize with a BIN file
97101 loc. Open (binfile, true );
98102
103+ // this is to initialize with a byte array
104+ // Path binpath = Paths.get(binfile);
105+ // byte[] binFileBytes = Files.readAllBytes(binpath);
106+ // loc.Open(binFileBytes);
107+
99108 IPResult rec = loc. IPQuery (ip);
100109 if (" OK" . equals(rec. getStatus()))
101110 {
Original file line number Diff line number Diff line change 3636 * <p>
3737 *
3838 * @author IP2Location.com
39- * @version 8.8 .0
39+ * @version 8.9 .0
4040 */
4141public class IP2Location {
4242 private static final Pattern pattern = Pattern .compile ("^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\ .){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" ); // IPv4
Original file line number Diff line number Diff line change 2828 * <p>
2929 *
3030 * @author IP2Location.com
31- * @version 8.8 .0
31+ * @version 8.9 .0
3232 */
3333public class IP2LocationWebService {
3434 private static final Pattern pattern = Pattern .compile ("^[\\ dA-Z]{10}$" );
Original file line number Diff line number Diff line change 99 * <p>
1010 *
1111 * @author IP2Location.com
12- * @version 8.8 .0
12+ * @version 8.9 .0
1313 */
1414public class IPResult {
1515 static final String NOT_SUPPORTED = "Not_Supported" ;
@@ -38,7 +38,7 @@ public class IPResult {
3838 String category ;
3939 String status ;
4040 boolean delay = false ;
41- String version = "Version 8.8 .0" ;
41+ String version = "Version 8.9 .0" ;
4242
4343 IPResult (String ipstring ) {
4444 ip_address = ipstring ;
Original file line number Diff line number Diff line change 3434 * <p>
3535 *
3636 * @author IP2Location.com
37- * @version 8.8 .0
37+ * @version 8.9 .0
3838 */
3939public class IPTools {
4040 private static final BigInteger MAX_IPV4_RANGE = new BigInteger ("4294967295" );
You can’t perform that action at this time.
0 commit comments