how to see the custom properties information in the Windows property on a specific file when i right click on it using Explore?

StackOverflow https://stackoverflow.com/questions/19970533

  •  30-07-2022
  •  | 
  •  

Pergunta

can anybody explain to me, how to proceed in the following scenario ?

I need to add custom properties(that is new metadata to a file like example classification_of_file with value sensitive) to all files like txt,pdf,doc,docx, ppt pptx , xls,xlsx etc.. using JAVA and then i want to see this custom properties information in the Windows property on a specific file when i right click on it using Explorer .

note:

  1. Is there any API using which i can do this ?
  2. Is it possible to do this by using Apache Jackrabbit?
Foi útil?

Solução

Are you talking about Windows property on a specific file when you right click on it using Explorer?

If so, you need to use the Java API for file attributes, precisely UserDefinedFileAttributeView.

You can use this view to write any property you may want on a specific file.

Path path = FileSystems.getDefault().getPath("C:/file.txt");
UserDefinedFileAttributeView view =
    Files.getFileAttributeView(path, UserDefinedFileAttributeView.class);
view.write("classification_of_file", Charset.defaultCharset().encode("sensitive"));

You can also call FileStore.supportsFileAttributeView() to check if your file system supports it.

You will find more explanations on file attributes in the Java documentation.

As for the second point, I don't know Apache Jackrabbit so I can't help you that much.

Outras dicas

Apache Jackrabbit will not help you set properties on a file that's stored in your filesystem.

It can nicely manage metadata of any kind for files that it stores itself, and which you can make available via WebDAV, but that requires storing files in the JCR repository.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top