code: 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);
          }
      }
docs: Extract zip or tar.gz archives to a target folder
  
  @param sourceURL url of the archive to extract
  @param targetFolder where to extract to
  @throws IOException on I/O error