public static void extract ( URL sourceURL , File targetFolder ) throws IOException { if ( sourceURL . getProtocol ( ) . equals ( "file" ) ) { if ( sourceURL . getFile ( ) . indexOf ( ".zip" ) > 0 ) { extractZipDistribution ( sourceURL , targetFolder ) ; } else if ( sourceURL . getFile ( ) . indexOf ( ".tar.gz" ) > 0 ) { extractTarGzDistribution ( sourceURL , targetFolder ) ; } else { throw new IllegalStateException ( "Unknow packaging of distribution; only zip or tar.gz could be handled." ) ; } return ; } if ( sourceURL . toExternalForm ( ) . indexOf ( "/zip" ) > 0 ) { extractZipDistribution ( sourceURL , targetFolder ) ; } else if ( sourceURL . toExternalForm ( ) . indexOf ( "/tar.gz" ) > 0 ) { extractTarGzDistribution ( sourceURL , targetFolder ) ; } else { throw new IllegalStateException ( "Unknow packaging; only zip or tar.gz could be handled. URL was " + sourceURL ) ; } }
Extract zip or tar . gz archives to a target folder