I would like to copy a file from one directory to another using Java and the FileUtils classes of apache org commons.
I wrote up a quick java program to test on my local system. Here is the code. The file exists, but the copying of the file to another directory isn't working. What am I missing? Is there some improper syntax somewhere?
import org.apache.commons.io.FileUtils;
import java.io.File;
class MoveFile {
public static void main(String[] args) {
MoveFile myobj = new MoveFile();
myobj.moveTheFile();
}
public void moveTheFile () {
try {
File destDir = new File("C:\\Folder1\\temp2");
File srcFile = new File("C:\\Folder1\\temp\\card.png");
FileUtils.copyFileToDirectory(srcFile, destDir);
} catch(Exception e) {
}
}
}