Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get URL using relative path

Tags:

java

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?

like image 587
Koerr Avatar asked Sep 08 '10 07:09

Koerr


People also ask

How do I get a relative URL?

To link pages using relative URL in HTML, use the <a> tag with href attribute. Relative URL is used to add a link to a page on the website. For example, /contact, /about_team, etc.

What is URL relative referencing?

A relative URL is a URL that only includes the path. The path is everything that comes after the domain, including the directory and slug. Because relative URLs don't include the entire URL structure, it is assumed that when linking a relative URL, it uses the same protocol, subdomain and domain as the page it's on.

What is relative and absolute path in URL?

An absolute URL contains all the information necessary to locate a resource. A relative URL locates a resource using an absolute URL as a starting point. In effect, the "complete URL" of the target is specified by concatenating the absolute and relative URLs.


1 Answers

new URL(url, relativePath); 
like image 157
Arne Deutsch Avatar answered Sep 28 '22 18:09

Arne Deutsch