3

I need to set user defined attributes for 2 reasons, 1- to mark encrypted files, 2- implementing a tag system like MacOS' Finder has.

Here's what I've tried:

Files.setAttribute(
    Paths.get("/storage/emulated/0/Download/21014040_9_Fizik_KTT.pdf"),
    "user:tagred",
    "testtesttest"
));

gives this error:

java.lang.UnsupportedOperationException: View 'user' not available

Path path = new File(filePath).toPath();
UserDefinedFileAttributeView view = Files.getFileAttributeView(path, UserDefinedFileAttributeView.class);

Here, view is null.

What should I use instead?

Shazniq
  • 423
  • 4
  • 16

0 Answers0