Class InetAddressUtil


  • public class InetAddressUtil
    extends java.lang.Object
    InetAddress utility methods.
    • Constructor Summary

      Constructors 
      Constructor Description
      InetAddressUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.net.InetSocketAddress[] getBroadcastAddresses​(int port)
      Get broadcast addresses.
      static java.lang.String getHostName()  
      static java.net.InetSocketAddress[] getSocketAddressList​(java.lang.String list, int defaultPort)
      Parse space delimited addresss[:port] string and return array of InetSocketAddress.
      static java.net.InetSocketAddress[] getSocketAddressList​(java.lang.String list, int defaultPort, java.net.InetSocketAddress[] appendList)
      Parse space delimited address[:port] string and return array of InetSocketAddress.
      static java.net.InetAddress intToIPv4Address​(int addr)
      Convert an integer into an IPv4 INET address.
      static int ipv4AddressToInt​(java.net.InetAddress addr)
      Convert an IPv4 INET address to an integer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • InetAddressUtil

        public InetAddressUtil()
    • Method Detail

      • getBroadcastAddresses

        public static java.net.InetSocketAddress[] getBroadcastAddresses​(int port)
        Get broadcast addresses.
        Parameters:
        port - port to be added to get socket address.
        Returns:
        array of broadcast addresses with given port.
      • intToIPv4Address

        public static java.net.InetAddress intToIPv4Address​(int addr)
        Convert an integer into an IPv4 INET address.
        Parameters:
        addr - integer representation of a given address.
        Returns:
        IPv4 INET address.
      • ipv4AddressToInt

        public static int ipv4AddressToInt​(java.net.InetAddress addr)
        Convert an IPv4 INET address to an integer.
        Parameters:
        addr - IPv4 INET address.
        Returns:
        integer representation of a given address.
        Throws:
        java.lang.IllegalArgumentException - if the address is really an IPv6 address
      • getSocketAddressList

        public static java.net.InetSocketAddress[] getSocketAddressList​(java.lang.String list,
                                                                        int defaultPort)
        Parse space delimited addresss[:port] string and return array of InetSocketAddress.
        Parameters:
        list - space delimited addresss[:port] string.
        defaultPort - port take if not specified.
        Returns:
        array of InetSocketAddress.
      • getSocketAddressList

        public static java.net.InetSocketAddress[] getSocketAddressList​(java.lang.String list,
                                                                        int defaultPort,
                                                                        java.net.InetSocketAddress[] appendList)
        Parse space delimited address[:port] string and return array of InetSocketAddress.
        Parameters:
        list - space delimited address[:port] string.
        defaultPort - port take if not specified.
        appendList - list to be appended.
        Returns:
        array of InetSocketAddress.
      • getHostName

        public static java.lang.String getHostName()