I'm trying to transfer over files from one directory to another. I am currently using this method to accomplish this task:
File srcDir = new File("path\to\file");
File destDIr = new File("path\to\file");
File.Utils.copyDirectory(srcDir, destDir);
However what I want is to not overwrite files that already exist in the destDir with the files in the srcDir.
For example if I have a file struct like:
├───srcDir
│ ├───this.txt
│ ├───hello.txt
│ ├───main.java
├───destDir
│ ├───this.txt
I want to copy over hello.txt
and main.java
however I do not want to copy/update/replace this.txt
I was thinking I could just check if file exists with something like
if(f.exists() && !f.isDirectory())
but that seems a little bit hacky and doesn't actually work the way I intend.
I'm looking for a common, simple way to do this, thank you.
Is there a solution that could also work with sub directories as well?