public void downloadAndUnzip ( ) { URL dataURL = null ; String fileName = folder + "/" + url . substring ( url . lastIndexOf ( "/" ) + 1 ) ; File compressedData = new File ( fileName ) ; if ( ! new File ( fileName ) . exists ( ) ) { try { dataURL = new URL ( url ) ; } catch ( MalformedURLException e ) { e . printStackTrace ( ) ; } try { assert dataURL != null ; FileUtils . copyURLToFile ( dataURL , compressedData ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } try { ZipFile zipFile = new ZipFile ( compressedData ) ; File dataFolder = new File ( folder ) ; zipFile . extractAll ( dataFolder . getCanonicalPath ( ) ) ; } catch ( ZipException | IOException e ) { e . printStackTrace ( ) ; } }
Downloads the file from the provided url and uncompresses it to the given folder .