Java API Tutorial - Java URL.sameFile(URL other)








Syntax

URL.sameFile(URL other) has the following syntax.

public boolean sameFile(URL other)

Example

In the following code shows how to use URL.sameFile(URL other) method.

import java.net.URL;
//w w w.  j  ava  2 s  .  c om
public class Main {
  public static void main(String[] argv) throws Exception {
    URL relativeURL, baseURL;
    baseURL = new URL("http://www.yourserver.com/");
    relativeURL = new URL(baseURL, "./a.htm");
    System.out.println(relativeURL.sameFile(baseURL));

  }
}

The code above generates the following result.