Class FileMerger

java.lang.Object
org.aksw.commons.io.util.FileMerger

public class FileMerger extends Object
Merges the byte content of a list of files into a single file. Use create(Path, List) to set up an instance of this class. Use run() to perform the merge. Calling run while another thread is already running raises an IllegalStateException. In principle, run be called again after another invocation completes in which the process with the exact same parameters is repeated; although typically the usefulness is limited.
Author:
Claus Stadler
  • Field Details

    • pathTransfers

      protected List<PathTransfer> pathTransfers
    • destPath

      protected Path destPath
    • totalTransferSize

      protected long totalTransferSize
    • runThread

      protected Thread runThread
    • transferred

      protected long transferred
    • progressListeners

      protected Collection<Consumer<? super FileMerger>> progressListeners
  • Constructor Details

    • FileMerger

      public FileMerger(Path destPath, List<PathTransfer> pathTransfers, long totalTransferSize)
  • Method Details

    • addProgressListener

      public Runnable addProgressListener(Consumer<? super FileMerger> progressListener)
    • notifyProgressListeners

      public void notifyProgressListeners()
    • getProgress

      public double getProgress()
      Convenience method that return the ration of transferred bytes and total bytes
    • abort

      public void abort()
    • run

      public void run() throws IOException
      Throws:
      IOException
    • create

      public static FileMerger create(Path destPath, List<Path> srcPaths) throws IOException
      Merge a sequence of files into a single destination file. The destination must not yet exist.
      Parameters:
      srcPaths -
      dest -
      Throws:
      IOException