I have a URL:
URL url=new URL("http://www.abc.com/aa/bb/cc/file.html");
and a relative path:
String relativePath="../file2.html"; //maybe is "/file3.html"
I want to get http://www.abc.com/aa/bb/file2.html
using variable url
and relativePath
How to do it? This is very frequent requirement you see if you are dealing with webservices development. One of the best answer i came across for this is:
new URL(url, relativePath);
toString() returns the string representation of the given URL object. For this case, toString() prints the url as http://www.abc.com/aa/bb/file2.html