private void cleanUpZipFile ( ) { long startTime = System . currentTimeMillis ( ) ; // Define ZIP File System Properties in HashMap Map < String , String > zip_properties = new HashMap <> ( ) ; // We want to read an existing ZIP File, so we set this to False zip_properties . put ( "create" , "false" ) ; // Specify the path to the ZIP File that you want to read as a File System // (File#toURI allows this to work across different operating systems, including Windows) URI zip_disk = URI . create ( "jar:" + new File ( outFile ) . toURI ( ) ) ; // Create ZIP file System try ( FileSystem fileSystem = FileSystems . newFileSystem ( zip_disk , zip_properties ) ) { // Get the Path inside ZIP File to delete the ZIP Entry for ( String fileName : emptyTableList ) { Path filePath = fileSystem . getPath ( fileName ) ; // Execute Delete Files . delete ( filePath ) ; LOG . info ( "Empty file {} successfully deleted" , fileName ) ; } } catch ( IOException e ) { LOG . error ( "Could not remove empty zip files" ) ; e . printStackTrace ( ) ; } LOG . info ( "Deleted {} empty files in {} ms" , emptyTableList . size ( ) , System . currentTimeMillis ( ) - startTime ) ; }
Removes any empty zip files from the final zip file .