Skip to content

Commit 65cb55b

Browse files
author
IPIP.net
committed
Update IPExt.java
增加load(filename, strict)方法,检查数据库文件大小。
1 parent f515445 commit 65cb55b

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

IPExt.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ public static void load(String filename) {
3535
watch();
3636
}
3737
}
38+
39+
public static void load(String filename, boolean strict) throws Exception {
40+
ipFile = new File(filename);
41+
if (strict) {
42+
int contentLength = Long.valueOf(ipFile.length()).intValue();
43+
if (contentLength < 512 * 1024) {
44+
throw new Exception("ip data file error.");
45+
}
46+
}
47+
load();
48+
if (enableFileWatch) {
49+
watch();
50+
}
51+
}
3852

3953
public static String[] find(String ip) {
4054
String[] ips = ip.split("\\.");

0 commit comments

Comments
 (0)