url.getFile() 和 getpath() 有什么区别? [英] What's the difference between url.getFile() and getpath()?

查看:40
本文介绍了url.getFile() 和 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 都会返回 x/y/z.html.

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

有人可以详细说明 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆