File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,7 +25,10 @@ Below are the methods supported in this class.
2525
2626| Method Name| Description|
2727| ---| ---|
28+ | public void Open(String DBPath, boolean UseMMF)| Initialize the component and preload the BIN file.|
29+ | public void Open(String DBPath)| Initialize the component and preload the BIN file.|
2830| IPQuery(String IPAddress)| Query IP address. This method returns results in com.ip2location.IPResult object.|
31+ | public void Close()| Destroys the mapped bytes.|
2932
3033## Result methods
3134Below are the result methods.
@@ -83,7 +86,9 @@ public class Main
8386 String binfile = " /usr/data/IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE.BIN" ;
8487
8588 IP2Location loc = new IP2Location ();
86- loc. IPDatabasePath = binfile;
89+ // loc.IPDatabasePath = binfile;
90+ loc. Open (binfile, true );
91+
8792 IPResult rec = loc. IPQuery (ip);
8893 if (" OK" . equals(rec. getStatus()))
8994 {
@@ -116,6 +121,10 @@ public class Main
116121 System . out. println(e);
117122 e. printStackTrace(System . out);
118123 }
124+ finally
125+ {
126+ loc. Close ();
127+ }
119128 }
120129}
121130```
You can’t perform that action at this time.
0 commit comments