Bug in Files.copy() where the source Path is a directory... It _is_ a bug, right?

Colin Decker cgdecker at google.com
Wed Dec 10 22:06:48 UTC 2014


On Wed Dec 10 2014 at 4:34:19 PM Alan Bateman <Alan.Bateman at oracle.com>
wrote:
>
> There have been requests over the years to add support for recursive copy,
> maybe a copyFileTree method but all suggestions to date didn't get to a
> consensus on how exceptions should be handled when only a subset of the
> file tree can be copied. Maybe some day.
>

I've implemented a secure (using SecureDirectoryStream) recursive delete; I
ended up choosing to attempt to delete all files, throwing a single
exception at the end with all the exceptions for individual files that
couldn't be deleted. Obviously there are a lot of other things you could
choose to do though.

On a related note, the fact that SecureDirectoryStream has neither a copy()
method nor a method for creating a directory makes me a little sad, as it
makes it impossible to implement a recursive copy that has similar security
guarantees.


>
> -Alan
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20141210/636b8f8d/attachment.html>


More information about the nio-dev mailing list