ip2location facebbook  ip2location twitter  ip2location google+ ip2location github

IP2Proxy Java Component

This Java component supports all IP2Proxy™ BIN database products to query proxy IP address and its country, region, city, ISP name and proxy types. It has been optimized for speed and memory utilization.

Source Source

 

Compilation
To compile IP2Proxy, run the following command
javac com/ip2proxy/*.java
jar cf ip2proxy.jar com/ip2proxy/*.class

 

Sample Codes
import com.ip2proxy.*;

public class Main {
    public Main() {
    }

    public static void main(String[] args) {
        try {
            IP2Proxy Proxy = new IP2Proxy();
            ProxyResult All;

            int IsProxy;
            String ProxyType;
            String CountryShort;
            String CountryLong;
            String Region;
            String City;
            String ISP;

            String IP = "221.121.146.0";

            if (Proxy.Open("/usr/data/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.BIN", IP2Proxy.IOModes.IP2PROXY_MEMORY_MAPPED) == 0) {
                System.out.println("GetModuleVersion: " + Proxy.GetModuleVersion());
                System.out.println("GetPackageVersion: " + Proxy.GetPackageVersion());
                System.out.println("GetDatabaseVersion: " + Proxy.GetDatabaseVersion());

                // reading all available fields
                All = Proxy.GetAll(IP);
                System.out.println("Is_Proxy: " + String.valueOf(All.Is_Proxy));
                System.out.println("Proxy_Type: " + All.Proxy_Type);
                System.out.println("Country_Short: " + All.Country_Short);
                System.out.println("Country_Long: " + All.Country_Long);
                System.out.println("Region: " + All.Region);
                System.out.println("City: " + All.City);
                System.out.println("ISP: " + All.ISP);

                // reading individual fields
                IsProxy = Proxy.IsProxy(IP);
                System.out.println("Is_Proxy: " + String.valueOf(IsProxy));

                ProxyType = Proxy.GetProxyType(IP);
                System.out.println("Proxy_Type: " + ProxyType);

                CountryShort = Proxy.GetCountryShort(IP);
                System.out.println("Country_Short: " + CountryShort);

                CountryLong = Proxy.GetCountryLong(IP);
                System.out.println("Country_Long: " + CountryLong);

                Region = Proxy.GetRegion(IP);
                System.out.println("Region: " + Region);

                City = Proxy.GetCity(IP);
                System.out.println("City: " + City);

                ISP = Proxy.GetISP(IP);
                System.out.println("ISP: " + ISP);
            }
            else {
                System.out.println("Error reading BIN file.");
            }
            Proxy.Close();
        }
        catch(Exception Ex) {
            System.out.println(Ex);
        }
    }
}

 

IP2Proxy LITE BIN Database

Developers may subscribe the free IP2Proxy LITE BIN database for testing and evaluation purpose. Please take note that the LITE database is limited to public proxies (PUB) IP address. Commercial databases consist of other proxy types such as Tor, VPN and etcs.