Reputation: 28188
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?
Upvotes: 16
Views: 17564
Reputation: 10900
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"
Upvotes: 0
Reputation: 4114
Gets the file name of this URL. The returned file portion will be the same as getPath(), plus the concatenation of the value of getQuery(), if any. If there is no query portion, this method and getPath() will return identical results.
Upvotes: 1
Reputation: 143886
The URL.getFile()
javadocs say this:
Gets the file name of this URL. The returned file portion will be the same as getPath(), plus the concatenation of the value of getQuery(), if any. If there is no query portion, this method and getPath() will return identical results.
They will be the same unless there is a query string, e.g. a ?somename=value&somethingelse=value2
in the URL.
Upvotes: 26