private String makeAbsolute ( String uri ) { if ( uri == null ) { uri = "" ; } try { URL url = new URL ( uri ) ; return url . toString ( ) ; } catch ( MalformedURLException mue ) { String dir = System . getProperty ( "user.dir" ) ; String file = "" ; if ( dir . endsWith ( "/" ) ) { file = "file://" + dir + uri ; } else { file = "file://" + dir + "/" + uri ; } try { URL fileURL = new URL ( file ) ; return fileURL . toString ( ) ; } catch ( MalformedURLException mue2 ) { // bail return uri ; } } }
Attempt to construct an absolute URI