Java URL getPath() Method

The getPath() method of URL class is used to get the path part of this URL. It returns an empty string if one does not exist.

Syntax

Returns

The path part of this URL, or an empty string if one does not exist

Since

1.3

Example 1

Output:

Url: https://www.javatpoint.com/collections-in-java#collectionmethods
Path of File in given url is : /collections-in-java

Example 2

Test it Now

Output:

Given URL is : https://localhost/notic/note.jsp
Path of url is : /notic/note.jsp
Next TopicJava URL Class




Latest Courses