Java URL getFile() 方法

2025年3月24日 | 阅读时间:2 分钟

URL 类的 getFile() 方法返回 URL 的文件名。返回的文件部分将与 getPath() 相同,并加上任何 getQuery() 的值(如果存在)。

语法

参数

不适用

返回值

此 URL 的文件名,如果不存在则为空字符串

示例 1

输出

Url: https://tpointtech.cn/java-threadpoolexecutor
File name in given url is : /java-threadpoolexecutor

示例 2

输出

Enter any url 
https://tpointtech.cn/java-threadpoolexecutor
File name in given url is : /java-threadpoolexecutor

示例 3

输出

Url1: https://tpointtech.cn/URL-class
 Url2: https://tpointtech.cn/URL-class
File name in given url1 is : /URL-class
File name in given url2 is : /URLConnection-class
下一个主题Java URL 类