I am doing testing against trying to view/edit/manipulate files that reside on a windows network share, and I have run into several instances across both uDig and GeoTools where java.net.URLs are (improperly?) converted into java.io.Files. The usual method of doing this is to just use URL.getPath:
File f = new File(url.getPath());
But if URL equals "file://E:/somedir/foo.tif", then File f is associated with the file "\somedir\foo.tif". The drive/network share information is lost.
The authority property contains this information:
String auth = url.getAuthority();
if (auth != null && !auth.equals("")) {
f = new File("//"+auth+url.getPath());
} else {
f = new File(url.getPath());
}
The variable 'auth' equals "E:" in this case, or "fooServer" if it is a network share. In uDig I have added a utility method to the URLUtils class. If someone wants this in GeoTools, tell me where to put it and I will.
It is a fair assumption that this happens a fair amount in our code, and I don't have time to go through the code base to check for instances of URL.getPath(), so I would just like to bring it to everyone's attention to keep an eye out for this.
Of course, if anyone has any better suggestions, please let me know. But for now I am fixing it in the image module, and I may fix it in shapefile next.
Richard
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Geotools-devel mailing list
Geotools-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/geotools-devel