ipaddress-5.0.2.jar使用方法-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

ipaddress-5.0.2.jar使用方法

package test;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import inet.ipaddr.IPAddress;
import inet.ipaddr.IPAddressString;
import inet.ipaddr.ipv4.IPv4Address;

public class TestIpAddr {

	public static void main(String[] args) {

		//ip转bigint
		IPAddress address = new IPAddressString("192.168.1.1").getAddress() ;
		System.out.println( address.getValue()  );
		
		// bigint转ip
		System.out.println(String.join(".",new IPv4Address(toByteArray(3232235777L)).getSegmentStrings()));

		//获取子网
		List subnetList = getSubnetList("192.168.1.1/255.255.252.0");
		
		for(int i=0;i getSubnetList (String ipAddr){

        IPAddress address = new IPAddressString(ipAddr).getAddress();
        int prefixLength=address.toAddressString().getNetworkPrefixLength();

        List subnetList = new ArrayList();

        IPAddress subnet = address.applyPrefixLength(prefixLength).toPrefixBlock();
        Iterator iterator = subnet.iterator();
        
        while (iterator.hasNext()) {
            subnetList.add(iterator.next().toCanonicalWildcardString());
        }
        subnetList.remove(0);
        subnetList.remove(subnetList.size()-1);
        return  subnetList;
    }
    

}

jar包下载地址:

漳浦网站制作公司哪家好,找创新互联!从网页设计、网站建设、微信开发、APP开发、响应式网站等网站项目制作,到程序开发,运营维护。创新互联2013年至今到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联。

https://www.mvnjar.com/com.github.seancfoley/ipaddress/5.0.2/detail.html


网站栏目:ipaddress-5.0.2.jar使用方法
网页地址:http://kswsj.cn/article/psjpjj.html

其他资讯