Dennis Kubes wrote:
If I call Path.toURI is essentially prints out the path without a scheme.

That's right. You've provided no scheme, and so have a scheme-independent path, a kind of relative path.

On the other hand if I create a file and call its toURI method I get a scheme.

Right, the scheme is known here, since it comes from a File.

If I try to create a URI without a scheme, the code errors out for not being an absolute path.

I don't see that demonstrated in your code. One can easily create URIs without a scheme. You try to create a File from a URI whose scheme is not "file", which is an error.

http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html#File(java.net.URI)

My question here is shouldn't the Path toURI method always return the full path with the scheme?

Where would the scheme come from? If you want a scheme-qualified path, and have a scheme, you can do this in various ways. For example, to default to the scheme of the default configured FileSystem, you'd:

Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(conf);
Path p = new Path("/home/dennis").makeQualified(fs);

or to hardwire the local filesystem, you could use any one of:

Path p = new Path("file", "", "/home/dennis");
Path p = new Path("file://" + "/home/dennis");
Path p = new Path("file:///", "/home/dennis");

The current behavior causes problems on local file system handling code, such as search servers in Nutch.

Can you elaborate?

Doug

Reply via email to