Java URI to Host Name getHost(URI uri)

Here you can find the source of getHost(URI uri)

Description

get Host

License

Apache License

Declaration

public static String getHost(URI uri) 

Method Source Code

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

import java.net.*;

public class Main {
    public static String getHost(URI uri) {
        String host = uri.getHost();
        int port = uri.getPort();

        if (port != -1) {
            host += ":" + port;
        }/*ww w .  ja va 2 s . c om*/
        return host;
    }

    public static int getPort(URI uri) {
        int port = uri.getPort();
        if (port == -1) {
            if ("https".equals(uri.getScheme()))
                port = 443;
            else
                port = 80;
        }
        return port;
    }
}

Related

  1. getHost(final URI uri)
  2. getHost(URI uri)
  3. getHost(URI uri)
  4. getHostAddress(final URI uri)
  5. getHostAddress(final URI uri)
  6. getHostAndPort(URI u)
  7. getHostFromURI(final URI uri)