Java URL getPath() 方法

2025年3月24日 | 1 分钟阅读

URL 类的 getPath() 方法用于获取此 URL 的路径部分。如果不存在路径,则返回一个空字符串。

语法

返回值

此 URL 的路径部分,如果不存在则为空字符串

自从 (Since)

1.3

示例 1

输出

Url: https://tpointtech.cn/collections-in-java#collectionmethods
Path of File in given url is : /collections-in-java

示例 2

输出

Given URL is : https:///notic/note.jsp
Path of url is : /notic/note.jsp
下一个主题Java URL 类