code: public static File uncompress(File sourceFile, File targetDir, boolean deleteSourceFileAfterUncompressed) throws FileAlreadyExistsException, IOException {
          //
          // figure out compression algorithm used by its extension
          //
          String fileExt = FileUtil.parseFileExtension(sourceFile.getName());
  
          // was a file extension parsed
          if (fileExt == null) {
              throw new IOException("File '" + sourceFile + "' must contain a file extension in order to lookup the compression algorithm");
          }
  
          // try to find compression algorithm
          Algorithm a = Algorithm.findByFileExtension(fileExt);
  
          // was it not found?
          if (a == null) {
              throw new IOException("Unrecognized or unsupported compression algorithm for file extension '" + fileExt + "'");
          }
  
          // make sure the destination directory is a directory
          if (!targetDir.isDirectory()) {
              throw new IOException("Cannot uncompress file since target directory " + targetDir + " neither exists or is a directory");
          }
  
          //
          // create a target file by stripping the file extension from the original file
          //
          String filename = sourceFile.getName();
          filename = filename.substring(0, filename.length()-(fileExt.length()+1));
  
          File targetFile = new File(targetDir, filename);
  
          uncompress(a, sourceFile, targetFile, deleteSourceFileAfterUncompressed);
  
          return targetFile;
      }
docs: Uncompresses the source file using a variety of supported compression
  algorithms.  This method will create a file in the target
  directory by stripping the compression algorithm's file extension from
  the source filename.  For example, using "gzip" will mean a source file of
  "app.log.gz" would be uncompressed to "app.log" and placed in the target
  directory.
  @param sourceFile The compressed file
  @param targetDir The target directory or null to uncompress in same directory as source file
  @param deleteSourceFileAfterUncompressed Delete the original source file
  only if the uncompression was successful.
  @return The uncompressed file
  @throws FileAlreadyExistsException Thrown if the target file already
  exists and an overwrite is not permitted.  This exception is a
  subclass of IOException, so its safe to only catch an IOException
  if no specific action is required for this case.
  @throws IOException Thrown if an error occurs while attempting to
  uncompress the source file.