Java Host Resolve resolveHostname()

Here you can find the source of resolveHostname()

Description

resolve Hostname

License

Apache License

Declaration

private static String resolveHostname() 

Method Source Code


//package com.java2s;
//License from project: Apache License 

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

public class Main {
    private static String resolveHostname() {
        InetAddress addr;//w  ww. j a v  a 2  s. co  m
        try {
            addr = InetAddress.getLocalHost();
        } catch (UnknownHostException uhe) {
            return "localhost";
        }
        return addr.getCanonicalHostName();
    }
}

Related

  1. resolve(String host, String path)
  2. resolveHost(String hostname)
  3. resolveHostname()
  4. resolveHostName()
  5. resolveHostName(final String hostName)
  6. resolveHostName(String hostname)