code: public static File compress(CompressionMethod _method, String _sourceFile, String _outputFileName) {
      	if (_method == null || _sourceFile == null) {
      		return null;
      	}
  
          File inputFile = new File(_sourceFile);
  
          if (!inputFile.exists()) {
              return null;
          }
  
          byte[] buffer = new byte[1024];
          try {
          	Constructor<? extends DeflaterOutputStream> constructor = _method.getOutputStreamClass().getConstructor(OutputStream.class);
          	if (constructor != null) {
          		DeflaterOutputStream compressOutputStream = constructor.newInstance(new FileOutputStream(_outputFileName));
  	            try (FileInputStream in = new FileInputStream(_sourceFile)) {
  	                int len;
  	                while ((len = in.read(buffer)) > 0) {
  	                    compressOutputStream.write(buffer, 0, len);
  	                }
  
  	                in.close();
  
  	                compressOutputStream.finish();
  	                compressOutputStream.close();
  	                return new File(_outputFileName);
  	            }
          	}
          } catch (IOException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException _ex) {
              LOGGER.error("Cannot uncompress file: ", _ex);
          }
          return null;
  
      }
docs: Compress a file using the given {@link CompressionMethod}.
  @param _method
  @param _sourceFile
  @param _outputFileName
  @return file object which represents the compressed file or null on error