url.getFile()和getpath()之间有什么区别? [英] What's the difference between url.getFile() and getpath()?
问题描述
在 java.net.url
中有 getFile()
方法和 getPath()
方法。
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.
例如, http://www.google.com/x/y/z.html
返回<两种方法的code> x / y / z.html 。
有人可以详细说明Javadocs吗?
Could someone elaborate on the Javadocs?
推荐答案
URL.getFile()
javadocs这样说:
The URL.getFile()
javadocs say this:
获取此URL的文件名。返回的文件部分将与getPath()相同,加上getQuery()的值的串联(如果有)。如果没有查询部分,则此方法和getPath()将返回相同的结果。
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.
除非有查询字符串,否则它们将是相同的,例如URL中的?somename = value& somethingelse = value2
。
They will be the same unless there is a query string, e.g. a ?somename=value&somethingelse=value2
in the URL.
这篇关于url.getFile()和getpath()之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!