code: public void compress() {
          compressionThread.submit(new Runnable() {
              public void run() {
                  try {
                      try (InputStream in = read();
                           OutputStream os = Files.newOutputStream(gz.toPath());
                           OutputStream out = new GZIPOutputStream(os)) {
                          org.apache.commons.io.IOUtils.copy(in, out);
                      }
                      // if the compressed file is created successfully, remove the original
                      file.delete();
                  } catch (IOException e) {
                      LOGGER.log(Level.WARNING, "Failed to compress "+file,e);
                      gz.delete(); // in case a processing is left in the middle
                  }
              }
          });
      }
docs: Asynchronously schedules the compression of this file.
  
  <p>
  Once the file is compressed, the original will be removed and
  the further reading will be done from the compressed stream.