patterntesting.runtime.net
Class Localhost

Package class diagram package Localhost
java.lang.Object
  extended by patterntesting.runtime.net.Localhost

public final class Localhost
extends 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
static Collection<InetAddress> getInetAddresses()
          Returns all local IP addresses.
static boolean matches(String host)
          Here we try to get all network addresses to compare it against the given hosts.
static boolean matches(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 Collection<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(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(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


Copyright © 2002–2014 PatternTesting Team. All rights reserved.