title: How can I make my method wait for a file to exist before continuing
body: <p>There is an external program that creates an XML file, but it may take a while to create.  I need my Java program to wait until the file exists before moving on.  </p>
  
  <p>I've been reading up a little bit about synchronized blocks, and I read that I can do something like this:</p>
  
  <pre><code>synchronized(this) {
      while (!file.exists) { this.wait(); }
  }
  </code></pre>
  
  <p>To be honest I don't really know much about synchronized tasks so I'm wondering if I'm on the right track, or if I'm way off.</p>