code: public static File compress(File sourceFile, String algorithm, boolean deleteSourceFileAfterCompressed) throws FileAlreadyExistsException, IOException {
          return compress(sourceFile, sourceFile.getParentFile(), algorithm, deleteSourceFileAfterCompressed);
      }
docs: Compresses the source file using a variety of supported compression
  algorithms.  This method will create a target file in the same
  directory as the source file and will append a file extension matching
  the compression algorithm used.  For example, using "gzip" will mean a
  source file of "app.log" would be compressed to "app.log.gz".
  @param sourceFile The uncompressed file
  @param algorithm The compression algorithm to use
  @param deleteSourceFileAfterCompressed Delete the original source file
  only if the compression was successful.
  @return The compressed 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
  compress the source file.