Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

file change notification

 
christophe seguinot
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm trying to implement a file change notification. I mean i want to be notifyed when some changes occured in a directory.
I can't use java 7 ...

I want to use DefaultFileMonitor from Apache common.


Here is a sample code which is working :


My problem comes from the Thread.sleep (20000), I would the program to run until explicitely called.

Any help would be appreciated.

Christohpe
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would the program to run until explicitely called.

For example, how do you intend to stop it ?
 
christophe seguinot
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fm.stop()
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mean the main program, when and how do you want to stop it ? You are watching a directory for changed, aren't you ? This is supposed to run until when ?
 
christophe seguinot
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will run this in a struts web application with start and stop button.
Thanks
 
christophe seguinot
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or I will start it in a filter and stop it in the destroy method of the servlet
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a web application, this will be fine, as you can leave the file monitor running until the web application is shutdown, or until you explicitly call the stop() method. But in your example, which is not a web application, you need some sort of information to make it stop. For example, you could loop for ever and wait until you press a certain key.
 
christophe seguinot
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic