Class NetworkUtil


  • public class NetworkUtil
    extends java.lang.Object
    Network utilities.
    • Constructor Summary

      Constructors 
      Constructor Description
      NetworkUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.net.InetAddress getLocalHostAddress()
      Gets the InetAddress of the localhost.
      • Methods inherited from class java.lang.Object

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

      • NetworkUtil

        public NetworkUtil()
    • Method Detail

      • getLocalHostAddress

        public static java.net.InetAddress getLocalHostAddress()
                                                        throws java.net.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:
        java.net.UnknownHostException - if the local host address could not be obtained