Yes, they are relative to the current directory of the file normally (the
current dir won't work since the file might not be there).

I was just surprised at the inflexibility since the file: scheme is not used
on the net. I understand that trying to convert from relative (without
scheme) to file is something that is not possible remotely, but those files
are on my filesystem.

As it is i had to do something like:

URI uri = URI.create(link);
String scheme = uri.getScheme();
if (scheme != null && scheme.startsWith("http")) {
//make a ad hoc conversion that downloads the file to the current dir and
treats it as a file that was there.
} else if (uri.getScheme() != null && uri.getScheme().equals("file")) {
//convert uri to file
} else if (uri.getScheme() == null) {
//convert relative URI to file with the current file parent dir as parent
}


On Mon, May 16, 2011 at 11:45 AM, Alan Bateman <alan.bate...@oracle.com>wrote:

>  Michael McMahon wrote:
>
> Paulo,
>
> URI's with a scheme (such as file:) cannot be relative. That's a feature of
> the specification of URIs themselves. So, this behavior is a side-effect of
> the
> requirement that the URI provided to the constructor has a file: scheme.
>
> Right, and I suspect the relative URIs that he has may actually be relative
> to a http URI rather than a file URI. If they are relative to a file URI
> then the question is what is the base. If the working directory then he can
> use new File("").toURI() as the base but it could be somewhere else.
>
> -Alan
>

Reply via email to