Files.createDirectories throws AccessDeniedException for an existing directory

Brian Burkhalter brian.burkhalter at oracle.com
Tue Mar 4 01:45:24 UTC 2025


Hello,

Looking at this again, I just wanted to clarify the calling situation. You have a Path something like

Path p = Path.of(“/“, “media”, “nfsvolume”, “dir”, “subdir”, “leafdir”);  // “/media/nfsvolume/dir/subdir/leafdir”

to an existing read-only directory “leafdir”, and you invoke createDirectories as

Path q = Files.createDirectories(p);

and either it works or it throws an AccessDeniedException?

Thanks,

Brian

> On Nov 26, 2024, at 8:44 AM, ole.sh at gmx.de wrote:
> 
> I came a across a behavior of Files.createDirectories on Linux (RHEL8, JDK 17) that is a litte "unexpected":
> The call of Files.createDirectories for an existing (and readable) directory on an NFS mount throws an AccessDeniedException. Technically this exception is correct because our process does not have the filesystem rights to create the directory, the process does have the rights to "read" the directory though.


More information about the nio-dev mailing list