public static boolean extractArchive ( File tarFile , File extractTo ) { try { TarArchive ta = getArchive ( tarFile ) ; try { if ( ! extractTo . exists ( ) ) if ( ! extractTo . mkdir ( ) ) throw new RuntimeException ( "Could not create extract dir: " + extractTo ) ; ta . extractContents ( extractTo ) ; } finally { ta . closeArchive ( ) ; } return true ; } catch ( FileNotFoundException e ) { log . error ( "File not found exception: " + e . getMessage ( ) , e ) ; return false ; } catch ( Exception e ) { log . error ( "Exception while extracting archive: " + e . getMessage ( ) , e ) ; return false ; } }
Extracts a . tar or . tar . gz archive to a given folder