Code example for URI

Methods: resolve

0
        URI base = new URI("http://host/a/b/c");
        assertEquals("http://host/a/d", base.resolve("../d").toString());
    } 
 
    public void testRelativeChildDirectory() throws Exception { 
        URI base = new URI("http://host/a/b/c");
        assertEquals("http://host/a/b/d/e", base.resolve("d/e").toString());
    } 
 
    public void testRelativeRootDirectory() throws Exception { 
        URI base = new URI("http://host/a/b/c");
        assertEquals("http://host/d", base.resolve("/d").toString());
    } 
 
    public void testRelativeFullUrl() throws Exception { 
        URI base = new URI("http://host/a/b/c");
        assertEquals("http://host2/d/e", base.resolve("http://host2/d/e").toString());
        assertEquals("https://host2/d/e", base.resolve("https://host2/d/e").toString());
    } 
 
Experience pair programming with AI  Get Codota for Java