I don't see a "simple" way of doing it with java.io classes, so here is a small method I'm using:
My directory looks like: /home/foo/templates/pattern /home/foo/templates/pattern/images (empty directory) /home/foo/templates/pattern/reports (empty directory) /home/foo/templates/pattern/web/1 (that is actually a file '1' with no extension)
I'm trying to copy from /home/foo/templates/pattern into /home/foo/instances/XX/
Where XX is a numbered instance of the pattern directory.
... if /a is a directory, then `cp -r /a /b' will copy /a to /b/a and /a/x to /b/a/x in case a directory /b existed already, but it will copy /a to /b and /a/x to /b/x if there was no /b beforehand, while it will fail in case there was an ordinary file /b.
(I was getting caught by the first case. I was creating my 'XX' directory beforehand).
She still doesn't approve of my superhero lifestyle. Or this shameless plug: