title: How to handle the JAVA WatchService Overflow event?
body: <p>I want to detect the <em>Creation</em> and <em>Modification</em> of files using JAVA. I am using the <strong>WatchService</strong> API provided by JDK 7.</p>
  
  <p>So, when there is multiple file creation at a given instance there is a level that the watch service can handle and then it generates and <strong>OVERFLOW</strong> event.</p>
  
  <p><em>Sample code part is provided below.</em></p>
  
  <p>What is the most suitable way to handle that situation when there is and overflow event thrown in order to detect the creation of all the files?</p>
  
  <pre><code>for (WatchEvent&lt;?&gt; event : key.pollEvents()) {
      WatchEvent.Kind kind = event.kind();
      // TBD - provide example of how OVERFLOW event is handled
      if (kind == OVERFLOW) {
           System.err.println("OVERFLOW !");
           continue;
      }
  }
  </code></pre>