Java file copy - how to inherit destination directory permissions
When I copy a file from the source folder to the destination folder, the destination folder permissions are not inherited by the newly copied file. is there a way in Java where copying a file to a destination inherits the permissions of the destination folder?
In java7 - You can do the following
Files.copy(source, target, StandardCopyOption.COPY_ATTRIBUTES)
I have not tested this code. Hope this helps!
Using Files.Copy works great and I tested this code where renameTo () or FileInput / OutputStream code didn't work.
Try it without StandardCopyOption and the permissions on the destination folder are automatically inherited like this:
Files.copy(source.toPath(), destination.toPath());
Hope this helps.