eeemt / phone-number-geo Goto Github PK
View Code? Open in Web Editor NEW离线查询手机号归属地
License: MIT License
离线查询手机号归属地
License: MIT License
没有 getter 方法
代码示例:
PhoneNumberInfo found = phoneNumberLookup.lookup(phone).orElse(getDefaultValue(phone));
执行此方法时,抛出异常:
java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer;
临时解决办法:获取源码,使用jdk8重新编译即可。
可能原因:已发布到重要仓库的包使用jdk1.8以上版本编译。
phoneNumberLookup.lookup 单实例,方法函数线程安全吗?
[ERROR threadPoolTaskScheduler-33 2020-08-27 11:35:30,232 --146919999(ms)]
[me.ihxq.projects.pna.PhoneNumberLookup.init(PhoneNumberLookup.java:47)]
failed to init PhoneNumberLookUp
java.io.IOException: Stale file handle
at java.io.RandomAccessFile.readBytes(Native Method)
at java.io.RandomAccessFile.read(RandomAccessFile.java:377)
at org.springframework.boot.loader.data.RandomAccessDataFile$DataInputStream.doRead(RandomAccessDataFile.java:184)
at org.springframework.boot.loader.data.RandomAccessDataFile$DataInputStream.read(RandomAccessDataFile.java:152)
at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:238)
at org.springframework.boot.loader.jar.ZipInflaterInputStream.fill(ZipInflaterInputStream.java:62)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
at org.springframework.boot.loader.jar.ZipInflaterInputStream.read(ZipInflaterInputStream.java:52)
at java.io.FilterInputStream.read(FilterInputStream.java:107)
at me.ihxq.projects.pna.PhoneNumberLookup.init(PhoneNumberLookup.java:35)
at me.ihxq.projects.pna.PhoneNumberLookup.(PhoneNumberLookup.java:64)
at me.ihxq.projects.pna.PhoneNumberLookup.(PhoneNumberLookup.java:56)
使用定时任务每隔1秒调用一次的时候会导致频繁的FGC
@scheduled(cron = " */1 * * * * ?")
public void test() {
log.info("===test===");
String number ="18625059406";
PhoneNumberInfo phoneNumberInfo = new PhoneNumberLookup().lookup(number).orElse(null);
if (ObjectUtils.isNotEmpty(phoneNumberInfo)) {
log.info(phoneNumberInfo.getAttribution().getProvince() + phoneNumberInfo.getAttribution().getCity());
}
这个init方法中没有释放资源,请问是这个原因导致的吗?
亲,更换最新版 phone.dat,只需要把源码目录下 得 phone.dat更换了,程序不需要改动吧?
测试号码:13333333333.
然后其他号码还乱码:
"attribution": {
"province": "璐靛窞",
"city": "璐甸槼",
"zipCode": "550000",
"areaCode": "0851"
},
升级数据版本至202302
1933737****
https://cx.shouji.360.cn/phonearea.php?number=1933737****
麻烦看下是否是问题
@
phone-number-geo/phone.dat 文件乱码 代码 函数 initData
try (InputStream inputStream = PhoneNumberGeo.class.getClassLoader().getResourceAsStream(PHONE_DAT_FILE_PATH)) {
几种算法中都存在未指定字符集编码 导致不同环境下会出现乱码的情况。都出现在lookup方法中,将bytes转成String的地方,需要手动传入字符编码:
将String oriString = new String(bytes)改为String oriString = new String(bytes, StandardCharsets.UTF_8)即可
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.