Java APIs to manage extended attributes
You can set, retrieve, and remove extended attributes on files, directories, and FUSE mounted file path using Extended Attribute Java APIs.
To set extended attributes, use the following APIs:
public void setXAttr(Path path, String name, byte[] value) throws
IOException".". For example, "user.attr".
By default, if a given extended attribute exists, then it will be replaced with the specified
attribute.public void setXAttr(Path path, String name, byte[] value,
Enum<SetXAttrSetFlag> flag) throws IOException".". For example, "user.attr".
The XAttrSetFlag value can be: CREATE to create a new extended attribute. An error is returned
if an extended attribute with the given name already exists.REPLACE to replace an existing extended attribute. An error is
returned if the specified extended attribute does not already exist.To retrieve extended attributes, use the following APIs:
public byte[] getXAttr(Path path, String name) throws IOException".". For example, "user.attr".public Map<String,byte[]> getXAttrs(Path path) throws
IOExceptionpublic Map<String,byte[]> getXAttrs(Path path, List<String> names) throws IOExceptionpublic List<String> listXAttrs(Path path) throws IOExceptionTo remove an extended attribute associated with a file or directory, use the following API:
public void removeXAttr(Path path, String name) throws
IOException".". For example,
"user.attr".