InetAddress: getCanonicalHostName()


import java.net.InetAddress;

public class Main {
  public static void main(String[] argv) throws Exception {
    InetAddress addr = InetAddress.getByName("127.0.0.1");
    byte[] ipAddr = new byte[] { 127, 0, 0, 1 };
    addr = InetAddress.getByAddress(ipAddr);
    // Get the host name
    String hostname = addr.getHostName();
    // Get canonical host name
    String canonicalhostname = addr.getCanonicalHostName();

  }
}
Home 
  Java Book 
    Networking  

InetAddress:
  1. InetAddress
  2. InetAddress: getAllByName(String name)
  3. InetAddress: getByName(String host)
  4. InetAddress: getCanonicalHostName()
  5. InetAddress: getHostAddress()
  6. InetAddress: getHostName()
  7. InetAddress: getLocalHost()
  8. InetAddress: isReachable(int timeout)