What's the difference between url.getFile() and getpath()?

Viewed 16050

In java.net.url there is a getFile() method and a getPath() method.

In my testing, they both return the same result: the full path and file after the domain name trailing slash.

For instance, http://www.google.com/x/y/z.html returns x/y/z.html for both methods.

Could someone elaborate on the Javadocs?

3 Answers

File, in the general case, is longer

new URL("http://www.google.com/x/y/z.html?v=1#chapter1").getFile();
// returns:  "/x/y/z.html?v=1"

, than Path:

new URL("http://www.google.com/x/y/z.html?v=1#chapter1").getPath();
// returns:  "/x/y/z.html"
Related