public static File getBundleFile ( Bundle bundle ) throws IOException { URL rootEntry = bundle . getEntry ( "/" ) ; //$NON-NLS-1$ rootEntry = FileLocator . resolve ( rootEntry ) ; if ( "file" . equals ( rootEntry . getProtocol ( ) ) ) //$NON-NLS-1$ return new File ( rootEntry . getPath ( ) ) ; if ( "jar" . equals ( rootEntry . getProtocol ( ) ) ) { //$NON-NLS-1$ String path = rootEntry . getPath ( ) ; if ( path . startsWith ( "file:" ) ) { // strip off the file: and the !/ path = path . substring ( 5 , path . length ( ) - 2 ) ; return new File ( path ) ; } } throw new IOException ( "Unknown protocol" ) ; //$NON-NLS-1$ }
Returns a file for the contents of the specified bundle . Depending on how the bundle is installed the returned file may be a directory or a jar file containing the bundle content .