public class FileOperations extends Object
Modifier and Type | Method and Description |
---|---|
static void |
copy(com.google.common.collect.ImmutableList<Path> sourceFiles,
Path destDir)
Copies
sourceFiles to the destDir directory. |
static OutputStream |
newLockingOutputStream(Path file)
|
public static void copy(com.google.common.collect.ImmutableList<Path> sourceFiles, Path destDir) throws IOException
sourceFiles
to the destDir
directory.sourceFiles
- the list of source files.destDir
- the directory to copy the files to.IOException
- if the copy fails.public static OutputStream newLockingOutputStream(Path file) throws IOException
FileLock
on the file
and opens an OutputStream
to
write to it. The file will be created if it does not exist, or truncated to length 0 if it does
exist. The OutputStream
must be closed to release the lock.
The locking mechanism should not be used as a concurrency management feature. Rather, this
should be used as a way to prevent concurrent writes to file
. Concurrent attempts to
lock file
will result in OverlappingFileLockException
s.
file
- the file to write toOutputStream
that writes to the fileIOException
- if an I/O exception occursCopyright © 2019. All rights reserved.