Skip to content

Commit d5184a5

Browse files
Update README.md
1 parent a2295f4 commit d5184a5

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff 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
3134
Below 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
```

0 commit comments

Comments
 (0)