3、ger log = Logger.getLogger(IPParser.class); 18. private String url; //ip查询请求地址 19. private String dbPath; //本地IP数据库地址 20. private String country, localStr; 21. private long IPN; 22. private int recordCount, countryFlag; 23. private long rangE, rangB, off
4、Set, startIP, endIP, firstStartIP,lastStartIP, endIPOff; 24. private RandomAccessFile fis; 25. private byte[] buff; 26. 27. private long B2L(byte[] b) { 28. long ret = 0; 29. for (int i = 0; i < b.length; i++) { 30. long t = 1L; 1.
5、 for (int j = 0; j < i; j++) 2. t = t * 256L; 3. ret += ((b[i] < 0) ? 256 + b[i] : b[i]) * t; 4. } 5. return ret; 6. } 7. 8. private long ipToInt(String ip) { 9. String[] arr = ip.split("\."); 10. long
6、ret = 0; 11. for (int i = 0; i < arr.length; i++) { 12. long l = 1; 13. for (int j = 0; j < i; j++) 14. l *= 256; 15. try { 16. ret += Long.parseLong(arr[arr.length - i - 1]) * l; 17. } catc