I have a directory:
| content
| - folderWithTextFile
| - - textFile.txt
| - - folderWithPdfFile
| - - - pdfFile.pdf
... and I want to merge it into another directory of the same name:
| content
| - folderWithExeFile
| - - exeFile.exe
| - - folderWithPngFile
| - - - pngFile.png
... so that I have this in the end:
| content
| - folderWithTextFile
| - - textFile.txt
| - - folderWithPdfFile
| - - - pdfFile.pdf
| - folderWithExeFile
| - - exeFile.exe
| - - folderWithPngFile
| - - - pngFile.png
Using Files.move(target, destination, StandardCopyOptions.REPLACE_EXISTING) gives me a DirectoryNotEmptyException as secondFolder is not empty.
Using Apache Commons IO FileUtils.moveDirectory(target, destination) gives a FileExistsException as the target already exists.
I would like a way to merge these two structures. It must copy the whole structure, not just one file.