JDK-6226081 : URI should be able to relativize paths with partial roots
  • Type: Enhancement
  • Status: Open
  • Resolution: Unresolved
  • Component: core-libs
  • Sub-Component: java.net
  • Priority: P4
  • Affected Version: 5.0
  • OS: windows_xp
  • CPU: x86
  • Submit Date: 2005-02-07
  • Updated Date: 2011-02-16
Description
A DESCRIPTION OF THE REQUEST :
At the moment, the relativize() method of URI will only  relativize URIs when one is a prefix of the other.  It would be useful, however to be able to do things like

    public static void main(String[] argv)
    {
        try
        {
            URI a = new URI("file:/c:/abc/def/myDocument/doc.xml");
            URI b = new URI("file:/c:/abc/def/images/subdir/image.png");
            
            URI c = a.relativize(b);
            
            System.err.println(c);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }

If this returned a URI of ../images/subdir/image.png,  it would make my job implementing editors much easier

JUSTIFICATION :
Current relativize method is too limited.
###@###.### 2005-2-07 10:44:17 GMT