Class NetworkUtil


  • public class NetworkUtil
    extends Object
    Network utilities.
    • Constructor Detail

      • NetworkUtil

        public NetworkUtil()
    • Method Detail

      • getLocalHostAddress

        public static InetAddress getLocalHostAddress()
                                               throws UnknownHostException
        Gets the InetAddress of the localhost. Attempts to get a non-loopback address (i.e. not 127.0.0.1) if at all possible. This utility is better than InetAddress.getLocalHost() since the latter often fails on Linux.
        Returns:
        the InetAddress of the localhost. This will be a non-loopback address if one could be found.
        Throws:
        UnknownHostException - if the local host address could not be obtained