Jody Garnett ha scritto:
> Hrm - I do see what you are talking about; the instructions on that page 
> are not the best.

Jody,
sometimes I wondering if you really read my mails ;-)

Please have a look in DataUtilities, there is no fileToURL method at
all, only the method to go the opposite direction is available (urlToFile).

Here is the file so that you can double check quickly:
http://svn.osgeo.org/geotools/trunk/modules/library/main/src/main/java/org/geotools/data/DataUtilities.java

The utility class you're referring to in uDig is:
http://svn.refractions.net/udig/udig/trunk/plugins/net.refractions.udig.catalog/src/net/refractions/udig/catalog/URLUtils.java

and the method is:

public static URL fileToURL( File file ) {
         try {
             return file.toURI().toURL();
         } catch (MalformedURLException e) {
             try {
                 return file.toURI().toURL();
             } catch (MalformedURLException e1) {
                 try {
                     return new URL("file:/" + 
file.getCanonicalPath().replace('\\', '/')); //$NON-NLS-1$
                 } catch (MalformedURLException e2) {
                     return null;
                 } catch (IOException e2) {
                     return null;
                 }
             }
         }
     }

The first try catch is ... odd? If the
first file.toURI().toURL() fails, what makes you think
the second attempt will work any better? ;-)

Can you make an example of a case that will fail
to work with toURI().toURL() that will work with
the innermost catch path?

Just asking so that I have a reason to reject the
user patch and use a sanitized version of the above
method instead.

Cheers
Andrea


-- 
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

------------------------------------------------------------------------------
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to