title: how to detect file has been deleted from within br.readline() loop
body: <p>Related to this question
  <a href="https://stackoverflow.com/questions/9164925/java-writing-to-a-deleted-file">Java writing to a deleted file</a>
  only in my case i'm doing the reading. And per that comment, yes, Windows block deletes and Unix doesn't. and under unix never throws any IOException </p>
  
  <p>the code is a poor-man's <code>tail -f</code>, where i have a java thread watching each log file in a directory. my current issue is if the file is deleted, i'm not handling it. I need to abort and start a new thread or something. I didn't even realize it was an issue, as the below code throws no exceptions under Unix</p>
  
  <p>the code </p>
  
  <pre><code>BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(f)));
  String line = null;
  
  while (true) {
      try {
          line = br.readLine();
          // will return null if no lines added
      } catch (IOException e) {
          e.printStackTrace();
      }
  
      if (line == null) {
          // sleep if no new lines added to file
          Thread.sleep(1000);
  
      } else {
          // line is not null, process line
      }
  }
  </code></pre>
  
  <p>Tomorrow I'll try adding this check before the sleep, maybe is sufficient </p>
  
  <pre><code>if (!f.exists()) {
      // file gone, aborting this thread
      return;
  }
  </code></pre>
  
  <p>Anyone have other ideas?</p>