public static String getUrlParentDir ( String url ) { try { UsableURI uri = UsableURIFactory . getInstance ( url ) ; String path = uri . getPath ( ) ; if ( path . length ( ) > 1 ) { int startIdx = path . length ( ) - 1 ; if ( path . charAt ( path . length ( ) - 1 ) == ' ' ) { startIdx -- ; } int idx = path . lastIndexOf ( ' ' , startIdx ) ; if ( idx >= 0 ) { uri . setPath ( path . substring ( 0 , idx + 1 ) ) ; uri . setQuery ( null ) ; return uri . toUnicodeHostString ( ) ; } } } catch ( URIException e ) { LOGGER . warning ( e . getLocalizedMessage ( ) + ": " + url ) ; } return null ; }
Find and return the parent directory of the URL argument