Java URL getPort() Method

The getPort() method of URL class returns the port number of the Specified URL.

Syntax

Returns

The port number, or -1 if the port is not set

Example 1

Test it Now

Output:

Url: http://127.0.0.1:8080/apex/f?p=4500:1001:2075345827901807::NO::
Port in given url is : 8080
Next TopicJava URL Class




Latest Courses