获取URL 信息(hutool方法)

Class URLUtil

URL(Uniform Resource Locator)统一资源定位符相关工具类

统一资源定位符,描述了一台特定服务器上某资源的特定位置。

URL组成:

   协议://主机名[:端口]/ 路径/[:参数] [?查询]#Fragment
   protocol :// hostname[:port] / path / [:parameters][?query]#fragment
static URI getHost(URL url)

获取URL中域名部分,只保留URL中的协议(Protocol)、Host,其它为null。

static String getPath(String uriStr)

获得path部分

URLUtil.getPath((String) jo.get("fileUrl")\

注意:path 中存在特殊字符无法识别

例: http://192.168.1.1/test/2021-10/测试(1).pdf

你可能感兴趣的:(java)