Monitoring a folder

Hi Guys!

i have strange requirement in one of project s where I need to monitor a folder. whenever a new file comes to that folder our program should be notified and execute accordingly by getting data from the file and insert into database.

Can any one suggest how it can be handled apart from threads becoz automatically we should be notified whenever a new file comes.

[390 byte] By [b_rajashekara] at [2007-10-3 8:13:45]
# 1
What's the platform?On Windows, there is an API for monitoring the file system. You could write a native method to do this from java.
bschauwejavaa at 2007-7-15 3:18:34 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2
I am working on windows xp.
b_rajashekara at 2007-7-15 3:18:34 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3
Java only based way - check all files within directory and compare with previous result. Workable but bit ugly.Native way - there are special WinAPI functions: FindFirstchangeNotification, FindNextchangeNotification, FindClosechangeNotification.
Michael.Nazarov@sun.coma at 2007-7-15 3:18:34 > top of Java-index,Java HotSpot Virtual Machine,Specifications...