mirror of
https://github.com/lionsoul2014/ip2region.git
synced 2025-12-08 19:25:22 +00:00
rename searchByStr to search and default the region encode to utf-8
This commit is contained in:
parent
4a2fae35e6
commit
cbf79d4682
@ -89,7 +89,7 @@ public class SearchTest {
|
||||
|
||||
try {
|
||||
double sTime = System.nanoTime();
|
||||
String region = searcher.searchByStr(line);
|
||||
String region = searcher.search(line);
|
||||
long cost = TimeUnit.NANOSECONDS.toMicros((long) (System.nanoTime() - sTime));
|
||||
System.out.printf("{region: %s, ioCount: %d, took: %d μs}\n", region, searcher.getIOCount(), cost);
|
||||
} catch (Exception e) {
|
||||
|
||||
@ -71,7 +71,7 @@ public class Searcher {
|
||||
return ioCount;
|
||||
}
|
||||
|
||||
public String searchByStr(String ipStr) throws Exception {
|
||||
public String search(String ipStr) throws Exception {
|
||||
long ip = checkIP(ipStr);
|
||||
return search(ip);
|
||||
}
|
||||
@ -135,7 +135,7 @@ public class Searcher {
|
||||
// load and return the region data
|
||||
final byte[] regionBuff = new byte[dataLen];
|
||||
read(dataPtr, regionBuff);
|
||||
return new String(regionBuff);
|
||||
return new String(regionBuff, "utf-8");
|
||||
}
|
||||
|
||||
protected void read(int offset, byte[] buffer) throws IOException {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user