Tuesday, December 27, 2011

Get the local hostname


<< Previous Table of Categories Next >>


 
   /**
   * Feel free to copy and use this. 
   * If you have any comments or better solutions, please paste on my blog: 
   * http://blog.yanmingyu.com or email me feedback.andrewyu@gmail.com 
 */ 
  public static String getLocalHostname()
    {
        String localHostname = null;
        try
        {
            InetAddress host = InetAddress.getLocalHost();
            localHostname = host.getHostName();
        }
        catch (Exception e)
        {
        }
        return localHostname;
    }

No comments:

Post a Comment