@Named @Singleton public class DefaultFileManager extends Object implements FileManager
FileManager.ProgressListener| Constructor and Description |
|---|
DefaultFileManager() |
| Modifier and Type | Method and Description |
|---|---|
void |
copy(File source,
File target) |
long |
copy(File source,
File target,
FileManager.ProgressListener listener)
Copy src- to target-file.
|
boolean |
mkdirs(File directory)
Null-safe variant of
File.mkdirs(). |
void |
move(File source,
File target) |
Lock |
readLock(File target)
Obtain a lock object that may be used to lock the target file for reading.
|
void |
write(File file,
InputStream source) |
void |
write(File file,
String data)
Write the given data to a file.
|
Lock |
writeLock(File target)
Obtain a lock object that may be used to lock the target file for writing.
|
public Lock readLock(File target)
FileManagerLock.lock()).readLock in interface FileManagertarget - the file to lock, never null.null.public Lock writeLock(File target)
FileManagerLock.lock()).writeLock in interface FileManagertarget - the file to lock, never null.null.public boolean mkdirs(File directory)
File.mkdirs().mkdirs in interface FileManagerdirectory - The directory to create, may be null.true if and only if the directory was created, along with all necessary parent
directories; false otherwisepublic void copy(File source, File target) throws IOException
copy in interface FileManagerIOExceptionpublic long copy(File source, File target, FileManager.ProgressListener listener) throws IOException
This method performs R/W-locking on the given files to provide concurrent access to files without data
corruption, and will honor FileLocks from an external process.
copy in interface FileManagersource - the file to copy from, must not be null.target - the file to copy to, must not be null.listener - the listener to notify about the copy progress, may be null.IOException - if an I/O error occurs.public void write(File file, InputStream source) throws IOException
write in interface FileManagerIOExceptionpublic void write(File file, String data) throws IOException
write in interface FileManagerfile - The file to write to, must not be null. This file will be truncated.data - The data to write, may be null.IOException - if an I/O error occurs.public void move(File source, File target) throws IOException
move in interface FileManagerIOExceptionCopyright © 2013–2016. All rights reserved.