Best way to Remove the domain from url
问题 I have to remove the domain's url from this: http://www.espn.com/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= decodeUrl.replace( "http://www.espn.com", "" ) Thanks 回答1: Use java.net.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. https://docs.oracle.com/javase/7/docs/api/java/net/URI.html URI uri = new