I've made this method that copies files from one absolute path (input directory) to another absolute path (output directory).
It doesn't give me any error, however no files are copied to the output folder.
Why would this be?
public static boolean copyFiles(String input, String output)
{
File source = new File(input);
File dest = new File(output);
try {
Files.copy(Paths.get(input), Paths.get(output), StandardCopyOption.REPLACE_EXISTING);
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
As @zapl said, Files.copy() only copies the directory.
I found the solution, by importing the Apache commons.io library.
org.apache.commons.io.FileUtils.copyDirectory(new File(input), new File(output));
This works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With