[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: java.io.File#toURI()
From: |
Jeroen Frijters |
Subject: |
RE: java.io.File#toURI() |
Date: |
Tue, 1 Jun 2004 17:49:13 +0200 |
Ito Kazumitsu wrote:
> I am afraid java.io.File#toURI() is not correctly implemented now.
I think I wrote that, but I don't know what I was smoking at the time.
> + return new URI("file", null, null, -1,
> + abspath.replace(separatorChar, '/'), null, null);
This isn't going to work on Windows. I don't really know what the right
solution is (file paths and URIs are driving me insane), but I think, at
the very least, we need something like this:
String path = abspath.replace(separatorChar, '/');
if(!path.startsWith("/"))
path = "/" + path;
return new URI(...);
Otherwise the "c:\foo.txt" style paths are handled incorrectly. For new
File("c:\\foo.txt").toURI().toString(), Sun returns "file:/c:/foo.txt".
Of course, there are also the UNC paths, which are even worse.
\\server\share\file is turned into file:////server/share/file by Sun.
Maybe this method needs to move to VMFile. Sigh.
Regards,
Jeroen