Apparently Java has quite a few known but practically undocumented issues with its handling of UNC paths under Windows. I’ve specifically encountered this bug albeit in a slightly different scenario:
@Testpublic void test() throws URISyntaxException { final URI uri = new URI( "file://c:/temp/test/ham.and.eggs" ); new File( uri ); // IllegalArgumentException thrown here}
/** * Resolves the specified URI, and returns the file * represented by the URI. * * @param uri The URI for which to return an absolute path. * @return The {@link File} instance represented by the * specified URI. * @throws IllegalArgumentException <ul><li>The URI cannot * be null.</li><li>Wrong URI scheme for path resolution; * only file:// URIs are supported.</li></ul> */public static File getFile( URI uri ) throws IllegalArgumentException { if ( uri == null ) throw new IllegalArgumentException( "The URI cannot be null." ); if ( !"file".equals( uri.getScheme() ) ) throw new IllegalArgumentException( "Wrong URI " + "scheme for path resolution, expected \"file\" " + "and got \"" + uri.getScheme() + "\"" ); // Workaround for the following bug: // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5086147 // Remove extra slashes after the scheme part. if ( uri.getAuthority() != null ) try { uri = new URI( uri.toString().replace( "file://", "file:/" ) ); } catch ( URISyntaxException e ) { throw new IllegalArgumentException( "The specified " + "URI contains an authority, but could not be " + "normalized.", e ); } return new File( uri );}
/** * Resolves the specified URI, and returns the file * represented by the URI. * * @param uri The URI for which to return an absolute path. * @return The {@link File} instance represented by the * specified URI. * @throws IllegalArgumentException <ul><li>The URI cannot * be null.</li><li>Wrong URI scheme for path resolution; * only file:// URIs are supported.</li></ul> */public static File getFile( URI uri ) throws IllegalArgumentException { if ( uri == null ) throw new IllegalArgumentException( "The URI cannot be null." );
if ( !"file".equals( uri.getScheme() ) ) throw new IllegalArgumentException( "Wrong URI " + "scheme for path resolution, expected \"file\" " + "and got \"" + uri.getScheme() + "\"" );
// Workaround for the following bug: // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5086147 // Remove extra slashes after the scheme part. if ( uri.getAuthority() != null ) try { uri = new URI( uri.toString().replace( "file://", "file:/" ) ); } catch ( URISyntaxException e ) { throw new IllegalArgumentException( "The specified " + "URI contains an authority, but could not be " + "normalized.", e ); }
return new File( uri );}
Remember Me
a@href@title, b, blockquote@cite, em, i, strike, strong, sub, super, u