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<String> subnetList = getSubnetList("192.168.1.1/255.255.252.0");
		
		for(int i=0;i<subnetList.size() ; i++ ) {
			System.out.println(subnetList.get(i) );
		}
	}