我必须从中删除域的网址: 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更多推荐
从网址中删除域的最佳方法
发布评论