[udig-devel] Udig on windows XP
Jody Garnett
jgarnett at refractions.net
Wed Dec 12 17:52:24 PST 2007
I found the following function in DataUtilities:
> /**
> * Takes a URL and converts it to a File. The attempts to deal with
> * Windows UNC format specific problems, specifically files located
> * on network shares and different drives.
> *
> * If the URL.getAuthority() returns null or is empty, then only the
> * url's path property is used to construct the file. Otherwise, the
> * authority is prefixed before the path.
> *
> * It is assumed that url.getProtocol returns "file".
> *
> * Authority is the drive or network share the file is located on.
> * Such as "C:", "E:", "\\fooServer"
> *
> * @param url a URL object that uses protocol "file"
> * @return a File that corresponds to the URL's location
> */
> public static File urlToFile (URL url) {
> String auth = url.getAuthority();
> String path = url.getPath();
> File f = null;
> if (auth != null && !auth.equals("")) {
> f = new File("//"+auth+path);
> } else {
> f = new File(path);
> }
> return f;
> }
This function has no test cases! If you can send me exact file names
that are failing for you I will try and
reproduce the problem as a test case.
In related research Java 6 has a new deprecation in this area;
- file.toURL() deprecated
- file.toURI().toURL() is okay
Chances are hacks like the above are in *everyones* code; so they were
unable to fix file.toURL(); and had to strictly define
file.toURL().toURI() instead.
Jody
More information about the udig-devel
mailing list