Java URI to Port getPort(URI uri)

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

Description

get Port

License

Apache License

Declaration

public static int getPort(URI uri) 

Method Source Code

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

import java.net.*;

public class Main {
    public static int getPort(URI uri) {
        int port = uri.getPort();
        if (port == -1) {
            if ("https".equals(uri.getScheme()))
                port = 443;// ww  w  . ja  v  a2 s.c  o  m
            else
                port = 80;
        }
        return port;
    }
}

Related

  1. getPort(URI uri)
  2. getPortFromURI(final URI uri)