0

I'm using the following Java code to create a file inside several folders:

Path pathOut = Paths.get("./", year, month, day, processId, "METADATA.txt");

File fileOut = pathOut.toFile();

boolean f = fileOut.getParentFile().mkdirs();

It works perfectly, but I'd need to set the permissions for each subfolder to '777'. Is it possible using mkdirs method or do I need to change the logic and use another approach?

Thanks!

Fel
  • 4,428
  • 9
  • 43
  • 94

1 Answers1

2

Permission 777 is the same as rwxrwxrwx. Thus, you can set the required permission as follows:

Files.setPosixFilePermissions(path, PosixFilePermissions.fromString("rwxrwxrwx"))
Arvind Kumar Avinash
  • 71,965
  • 6
  • 74
  • 110