Basically in the Files.createFile(Path fileName, FileAttribute<?>... attrs );
there is the possibility to insert a series of attributes. I am aware of the following possibility:
Path path = Paths.get(path...);//the file path
PosixFileAttributes attr = Files.readAttributes(path,PosixFileAttributes.class);
Set<PosixFilePermission> permissions = attr.permissions();
FileAttribute<Set<PosixFilePermission>> attra
= PosixFilePermissions.asFileAttribute(permissions);
Files.createFile(path,attra);
Do you know any other real life application of the createFile()
method? And with other application I mean other attributes passed as a FileAttribute parameter other than a set of PosixFilePermission? What are other "passable" FileAttribute parameter that I can use to create a new file with File.createFile(path, attr);
?
Thanks in advance.
Yes, the Access Control Lists (ACL) attributes.
See Java 7 Documentation for AclFileAttributeView for how to use them with createFile
and createDirectory
methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With