title: Java detect changes in filesystem
body: <p>I have a folder in which continuously new files are being dumped.In Java,what is the best way to detect changes in file-system (ie. a specified folder in which the files are being dumped) and add the newly arrived files to a queue data structure so that i can sequentially process each incoming file.</p>
  
  <p>I'm aware of listFiles() function in the File class but using this I can only get files that are available at an instant of time. Of course I can continuously poll the  folder and get the list of files in it using a thread.But is this the best way or is there a better way to accomplish this.</p>