Class Localhost


  • public final class Localhost
    extends java.lang.Object
    This (static) class represents your local host. You can ask it for the local address and other things.
    Since:
    1.0 (30.01.2010)
    Author:
    oliver
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Collection<java.net.InetAddress> getInetAddresses()
      Returns all local IP addresses.
      static boolean matches​(java.lang.String host)
      Here we try to get all network addresses to compare it against the given hosts.
      static boolean matches​(java.lang.String[] hosts)
      Here we try to get all network addresses to compare it against the given hosts.
      • Methods inherited from class java.lang.Object

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

      • getInetAddresses

        public static java.util.Collection<java.net.InetAddress> getInetAddresses()
        Returns all local IP addresses. If you want to get the local host name use InetAddress.getLocalHost().
        Returns:
        a list of the host addresses
      • matches

        public static boolean matches​(java.lang.String[] hosts)
        Here we try to get all network addresses to compare it against the given hosts. The host can be given as hostname (e.g. "localhost") or as IP address (e.g. "127.0.0.1").
        Parameters:
        hosts - an array of hosts
        Returns:
        true if matches one of the given hosts.
      • matches

        public static boolean matches​(java.lang.String host)
        Here we try to get all network addresses to compare it against the given hosts.
        Parameters:
        host - either IP address (e.g. "127.0.0.1") or hostname (e.g. "localhost")
        Returns:
        true if matches the given host