Skip to content

Commit a2295f4

Browse files
Added Open methods to allow initialization with params and preload the BIN file
1 parent 2e12575 commit a2295f4

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

com/ip2location/IP2Location.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* <p>
3737
*
3838
* @author IP2Location.com
39-
* @version 8.3.0
39+
* @version 8.4.0
4040
*/
4141
public 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
@@ -145,6 +145,23 @@ public IP2Location() {
145145

146146
}
147147

148+
149+
/**
150+
* This function can be used to pre-load the BIN file.
151+
*/
152+
public void Open(String DBPath) throws IOException {
153+
IPDatabasePath = DBPath;
154+
LoadBIN();
155+
}
156+
157+
/**
158+
* This function can be used to initialized the component with params and pre-load the BIN file.
159+
*/
160+
public void Open(String DBPath, boolean UseMMF) throws IOException {
161+
UseMemoryMappedFile = UseMMF;
162+
Open(DBPath);
163+
}
164+
148165
/**
149166
* This function destroys the mapped bytes.
150167
*/

com/ip2location/IPResult.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* <p>
1010
*
1111
* @author IP2Location.com
12-
* @version 8.3.0
12+
* @version 8.4.0
1313
*/
1414
public class IPResult {
1515
static final String NOT_SUPPORTED = "Not_Supported";
@@ -36,7 +36,7 @@ public class IPResult {
3636
String usagetype;
3737
String status;
3838
boolean delay=false;
39-
String version = "Version 8.3.0";
39+
String version = "Version 8.4.0";
4040
IPResult(String ipstring) {
4141
ip_address = ipstring;
4242
}

0 commit comments

Comments
 (0)