Here you can find the source of getPort(URI uri)
public static int getPort(URI uri)
//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; } }