Package org.aksw.commons.io.util
Class FileMerger
java.lang.Object
org.aksw.commons.io.util.FileMerger
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 Summary
FieldsModifier and TypeFieldDescriptionprotected Pathprotected List<PathTransfer>protected Collection<Consumer<? super FileMerger>>protected Threadprotected longprotected long -
Constructor Summary
ConstructorsConstructorDescriptionFileMerger(Path destPath, List<PathTransfer> pathTransfers, long totalTransferSize) -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()addProgressListener(Consumer<? super FileMerger> progressListener) static FileMergerMerge a sequence of files into a single destination file.doubleConvenience method that return the ration of transferred bytes and total bytesvoidvoidrun()
-
Field Details
-
pathTransfers
-
destPath
-
totalTransferSize
protected long totalTransferSize -
runThread
-
transferred
protected long transferred -
progressListeners
-
-
Constructor Details
-
FileMerger
-
-
Method Details
-
addProgressListener
-
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
- Throws:
IOException
-
create
Merge a sequence of files into a single destination file. The destination must not yet exist.- Parameters:
dest-srcPaths-- Throws:
IOException
-