Java Host Name Get getHostname(String targetEndpoint)

Here you can find the source of getHostname(String targetEndpoint)

Description

get Hostname

License

Apache License

Declaration

public static String getHostname(String targetEndpoint) 

Method Source Code

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

import java.net.URI;

public class Main {
    public static String getHostname(String targetEndpoint) {
        try {/*from   ww w  .  j a v a2s.co m*/
            URI uri = new URI(targetEndpoint);
            return uri.getHost();
        } catch (Exception e) {
            return "localhost";
        }
    }
}

Related

  1. getHostname()
  2. getHostName()
  3. getHostName(Proxy proxy)
  4. getHostName(String destination)
  5. getHostName(String host)
  6. getHostNameByInet()
  7. getHostNameByNic()
  8. getHtmlSource(final String host)
  9. getInetHost()