I'm working on a program in which I want to add the possibility of copy-pasting (or cut-pasting) files. I could create it so it only works within the program, but it would be nicer if I could use the system-wide clipboard. That has one huge problem though: when pasting I don't know if files are copied or cut from the system explorer, I only get the file locations.
I am using Java and the javafx clipboard. Some sample code:
Clipboard clipboard = Clipboard.getSystemClipboard();
List<File> files = clipboard.getFiles();
// destDir is a File, the target directory.
for (File oldFile : files) {
if (oldFile.isDirectory()) {
FileUtils.copyDirectoryToDirectory(oldFile, destDir);
} else {
FileUtils.copyFileToDirectory(oldFile, destDir);
}
}
Here I simply copy the files, but how do I for example know when to use FileUtils.copyDirectoryToDirectory
and when to use FileUtils.moveDirectoryToDirectory
(aka copy or cut)?
Thanks,
Luca