public static String getFileNameFromURI ( final URI resourceAddress , final boolean usePathStyleUris ) { // generate an array of the different levels of the path final String [ ] pathSegments = resourceAddress . getRawPath ( ) . split ( "/" ) ; // usePathStyleUris ? baseuri/accountname/sharename/objectname : accountname.baseuri/sharename/objectname final int shareIndex = usePathStyleUris ? 2 : 1 ; if ( pathSegments . length - 1 <= shareIndex ) { // legal file addresses cannot end with or before the sharename throw new IllegalArgumentException ( String . format ( "Invalid file address '%s'." , resourceAddress ) ) ; } else { // in a legal file address the lowest level is the filename return pathSegments [ pathSegments . length - 1 ] ; } }
Gets the file name from the URI .