Java DNS getDNSName(String s)

Here you can find the source of getDNSName(String s)

Description

get DNS Name

License

Open Source License

Declaration

public static String getDNSName(String s) 

Method Source Code


//package com.java2s;
import java.net.InetAddress;
import java.net.UnknownHostException;

public class Main {
    private static boolean enableDNS = true;

    public static String getDNSName(String s) {
        if (!enableDNS)
            return s;
        String s1;/* w ww . java 2 s.  c  o m*/
        try {
            InetAddress inetaddress = InetAddress.getByName(s);
            s1 = inetaddress.getHostName().trim();
        } catch (UnknownHostException unknownhostexception) {
            s1 = s;
        }
        return s1.toLowerCase();
    }
}

Related

  1. getDnsDomainName()
  2. resolveDNS(String dns)