从网址中删除域的最佳方法

编程入门 行业动态 更新时间:2024-10-23 09:26:50
本文介绍了从网址中删除域的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我必须从中删除域的网址: www.espn/watch/?gameId=1234&league=nfl&lang=es&profile=sportscenter_v1

I have to remove the domain's url from this: www.espn/watch/?gameId=1234&league=nfl&lang=es&profile=sportscenter_v1

您知道不使用类似方法来实现此目标的更好方法吗?

Do you know a better way to achieve that without using things like:

def example = encodeUrl.replace(" www.espn "," )

def example= decodeUrl.replace( "www.espn", "" )

谢谢

推荐答案

使用java.URI类.如果从url字符串创建URI,则可以访问地址,行,路径,查询,方案,主机端口等的所有组件. docs. oracle/javase/7/docs/api/java/net/URI.html

Use java.URI class. If you create URI from url String, you will have access to all components of the address, line, path, query, scheme, host port etc. docs.oracle/javase/7/docs/api/java/net/URI.html

URI uri = new URI("www.espn/watch/?gameId=1234&league=nfl&lang=es&profile=sportscenter_v1") println uri.path +"?"+ uri.query

更多推荐

从网址中删除域的最佳方法

本文发布于:2023-11-01 18:26:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550075.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网址   方法

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!