Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

listener to the folder changes in java application.

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

My requirement in my project to monitor a folder. Whenever a xml file gets added or xml file present in that folder gets updated i need to listen to those changes and parse the xml file to get the message. Do you have clue how we can approch that. I thought of using quartz but schedular will execute the job for every certain interval of time instead of executing the job whenever folder gets modified. Whether can we use joblistener or triggerlistener?
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might find this discussion useful.
 
Rancher
Posts: 4686
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assuming you can be happy with "reasonably quick" notification, say once a minute, its easy.

Better approach is to have a daemon thread sleep, look for file, and if its there, immediately rename it to another directory.
Then release semaphore or other sync technique, to have the "worker" thread do the processing while the "checking" thread takes a nap and does the next lookup.

Its only 30 or so lines of code.
 
pavithra M K
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all for your replies.

i have thought of using JDK1.7 API's for folder monitoring, however JDK1.7 is not yet released we cannot suggest this to customers. And we dont want to use Threads here.

Can i use quartz- job, schedular and trigger listener in this scenario.

JOb -to read the xml file.
trigger listener - to listen to the folder changes and execute the Job.

Actually i want to know how to use trigger listener or job listener or schedule listener in my Java Application.
 
Marshal
Posts: 71720
312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pavithra M K please read the important administrative private message I just sent you.
 
If you have a bad day in October, have a slice of banana cream pie. And this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic