Java Utililty Methods Local Host Get

List of utility methods to do Local Host Get

Description

The list of methods to do Local Host Get are organized into topic(s).

Method

byte[]createLocalHostID(int size)

Generates a byte array of the given size that should be a value unique to the host on which the current Java virtual machine is running.

if (size < 0)
    throw new NegativeArraySizeException(
            "Cannot create a unique host ID value with a negative array size.");
byte[] hostAddress = null;
String hostname = null;
try {
    InetAddress hostInetAddress = java.net.InetAddress.getLocalHost();
    hostAddress = hostInetAddress.getAddress();
...
ListgetAllLocalHostNames()
get All Local Host Names
List<String> localNames = new ArrayList<String>();
Enumeration<NetworkInterface> e = null;
try {
    e = NetworkInterface.getNetworkInterfaces();
} catch (SocketException exception) {
    throw new RuntimeException(exception);
for (; e.hasMoreElements();) {
...
StringgetCanonicalLocalHostName()
Returns canonical name (fully qualified domain name) of the localhost.
try {
    final InetAddress localHost = InetAddress.getLocalHost();
    return localHost.getCanonicalHostName();
} catch (final UnknownHostException ex) {
    return "localhost";
StringgetCanonicalLocalHostName()
get Canonical Local Host Name
try {
    InetAddress localhost = InetAddress.getLocalHost();
    return localhost.getCanonicalHostName();
} catch (UnknownHostException e) {
    return getLocalAddressAsString();
InetAddressgetLocalHost()
Get a cached copy of the local host.
if (localHost == null) {
    try {
        localHost = InetAddress.getLocalHost();
    } catch (UnknownHostException e) {
        localHost = InetAddress.getByName(LOCALHOST);
return localHost;
...
InetAddressgetLocalHost()
Gets the set localhost address
return localhost;
StringgetLocalhost()
Gets the hostname of localhost
String hostname = null;
try {
    InetAddress addr = InetAddress.getLocalHost();
    hostname = addr.getHostName();
} catch (UnknownHostException e) {
    throw new RuntimeException("[FileHelper] {getLocalhost}: Can't get local hostname");
return hostname;
...
StringgetLocalHost()
get Local Host
if (_localHost != null)
    return _localHost;
try {
    InetAddress addr = InetAddress.getLocalHost();
    _localHost = addr.getHostName();
} catch (Exception e) {
    _localHost = "127.0.0.1";
return _localHost;
InetAddressgetLocalHost()
get Local Host
return InetAddress.getLocalHost();
InetSocketAddressgetLocalHost()
get Local Host
try {
    final InetSocketAddress addr;
    final InetAddress local = InetAddress.getLocalHost();
    addr = new InetSocketAddress(local, 0);
    if (printLocalHost) {
        printLocalHost = false;
        System.out.println();
        System.out.println("\t\tLocal host used in tests:");
...