All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.att.nsa.util.HostInfo Maven / Gradle / Ivy

There is a newer version: 1.2.0-oss
Show newest version
/*******************************************************************************
 * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved.
 *******************************************************************************/
package com.att.nsa.util;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class HostInfo
{
	/**
	 * Get this system's hostname for use in applications like logging,
	 * but not as a reliable name for the system. There are too many
	 * problems with an application identifying its host's name to rely
	 * on the information retrieved from the system.
	 * @return the host's likely name
	 */
	public static String getHostNameForLog ()
	{
		try
		{
			return InetAddress.getLocalHost ().getCanonicalHostName ();
		}
		catch ( UnknownHostException e )
		{
			return "localhost";
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy