IPIP.net官方支持的解析datx格式的Java代码
Switch branches/tags
Nothing to show
Clone or download
Latest commit 0bb59e8 Jun 25, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
datx/src/net/ipip/datx update Mar 9, 2018
.gitignore Initial commit Mar 4, 2018
LICENSE Initial commit Mar 4, 2018
README.md update Jun 25, 2018

README.md

datx-java

IPIP.net官方支持的解析datx格式的Java代码

示例代码


import net.ipip.datx.*;

import java.io.IOException;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {

        try {
            City city = new City("/path/to/mydata4vipday4.datx"); // 城市库

            System.out.println(Arrays.toString(city.find("8.8.8.8")));
            System.out.println(Arrays.toString(city.find("255.255.255.255")));

            District district = new District("/path/to/quxian.datx");//区县库

            System.out.println(Arrays.toString(district.find("1.12.0.0")));
            System.out.println(Arrays.toString(district.find("223.255.127.250")));

            BaseStation baseStation = new BaseStation("/path/to/station_ip.datx"); // 基站库

            System.out.println(Arrays.toString(baseStation.find("8.8.8.8")));
            System.out.println(Arrays.toString(baseStation.find("223.221.121.0")));

        } catch (IOException ioex) {
            ioex.printStackTrace();
        } catch (IPv4FormatException ipex) {
            ipex.printStackTrace();
        }
    }
}