code: private void mergeFiles(List<File> inputFiles, OutputStream outputStream)
        throws IOException {
      long startTime = System.nanoTime();
  
      //Merge files
      for (File f : inputFiles) {
        if (f.exists()) {
          FileInputStream fileInputStream = new FileInputStream(f);
          BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
          try {
            LOGGER.log(Level.INFO, "Merging {0} size={1}", new Object[]{f.getName(), f.length()});
  
            byte[] buffer = new byte[8192];
            int length;
            while ((length = bufferedInputStream.read(buffer)) > 0) {
              outputStream.write(buffer, 0, length);
            }
          } finally {
            bufferedInputStream.close();
            fileInputStream.close();
          }
        } else {
          LOGGER.log(Level.INFO, "Skip merging file {0} because it doesn't exist", f.getName());
        }
      }
  
      LOGGER.log(Level.INFO, "Time to merge {0} s", ((System.nanoTime() - startTime) / 1000000000.0));
    }
docs: Merge files to the provided fileChannel