Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java File copy - how to inherit permissions of destination directory

Tags:

java

file

copy

When I copy a file from source folder to destination folder the permissions of the destination folder are not inherited by newly copied file. is there a way in Java where file copy to destination would inherit permissions of destination folder?

like image 772
Sandy Avatar asked Oct 20 '22 21:10

Sandy


1 Answers

In java7 - You can do the following

Files.copy(source, target, StandardCopyOption.COPY_ATTRIBUTES)

I have not tested this code. Hope it helps!!

like image 144
Ouney Avatar answered Oct 22 '22 10:10

Ouney