Javatpoint Logo
Javatpoint Logo

Java URL sameFile Method

The sameFile() method of URL class compares two URLs, excluding the fragment component. It returns true if this URL and the other argument are equal without considering the fragment component.

Syntax

Parameter

other - the URL to compare against.

Returns

true if they reference the same remote object; false otherwise.

Example 1

Output:

Url1 : https://www.javatpoint.com/aptitude/quantitative
Url2 : https://www.javatpoint.com/
 ***** compareing both url ***** 
 Both url has different file 

Example 2

Output:

Enter any url 
https://www.javatpoint.com/
File of Both url are equal : true

Example 3

Output:

Both BaseUrl and relativeURL are equal? : false
Next TopicJava URL Class





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA