Reputation: 92550
I want to copy a directory tree with empty (but necessary!) directories with apache commons io 2.1. But it doesn't copy empty directories!
My code looks like this:
FileUtils.copyDirectory(new File(sourceDir), new File(targetDir));
Can I tell FileUtils
to copy empty directories too? Or is it a bug in "commons io"?
Upvotes: 1
Views: 1031
Reputation: 421290
I just tested this myself using apache commons 2.1 (using the code line below) and for me it does copy empty directories too.
FileUtils.copyDirectory(new File("/home/aioobe/tmp/new_test"),
new File("/home/aioobe/tmp/new_test_2"));
with this structure
/home/aioobe/tmp/new_test
hello.txt
emptyDir/
Both hello.txt
and emptyDir
showed up in new_test_2
as well.
Perhaps an SSCCE would be useful.
Upvotes: 6