title: How to Wait for windows process to finish before opening file in java
body: <p>I have a implemented a listener that notifies if we receive a new file in a particular directory. This is implemented by polling and using a TimerTask. 
  Now the program is so set up that once it receives a new file it calls another java program that opens the file and validates whether it is the correct file. My problem is that since the polling happens a specified number of seconds later there can arise a case in which a file is being copied in that directory and hence is locked by windows. </p>
  
  <p>This throws an IOException since the other java program that tries to open it for validation cannot ("File is being used by another process"). </p>
  
  <p>Is there a way I can know when windows has finished copying and then call the second program to do the validations from java? </p>
  
  <p>I will be more than happy to post code snippets if someone needs them in order to help. </p>
  
  <p>Thanks</p>