• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is it possible to receive filesystem events?  RSS feed

 
Manuel Moons
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Does anyone know if it is possible to receive events whenever a file or directory changes.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Short answer: no. The designers of Java drew a line and decided that was an operating system specific function that did not meet their portability needs.

A couple options: Periodically list a directory and compare the results to the prior list. Kinda ugly and might be non-performant. (Isn't that a cool new buzzword!)

Another option might be to write a C/C++ module that subscribes to the OS filesystem events and forwards them via JNI to Java. You might even be able to share that as a useful open-source project.
 
Manuel Moons
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Stan,

I knew that I would need a native library. I was hoping however that there was one already. I think we will probably write a library like that and maybe we can share it with the rest of the world. I will have to talk to my boss about that.

Anyway thank you for your help.
 
Greg T Robertson
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not affiliated never used but this may fill the bill
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!