Java URL class getDefaultPort() MethodThe getDefaultPort() method of URL class is used to get the default port number of the protocol associated with given URL. If the URL scheme or the URLStreamHandler for the URL does not define a default port number, then -1 is returned. SyntaxReturnsthe port number Since1.4 Example 1Output: Enter Url https://www.javatpoint.com/java-date The Defaultport of the given url is : 443 Example 2Test it NowOutput: Given URL is : https://www.google.com/ Default Port 443 Protocal https Host www.google.com
Next TopicJava URL Class
|