title: Delete Files with same Prefix String using Java
body: <p>I have around 500 text files inside a directory with each with the same prefix in their filename, for example: <code>dailyReport_</code>.</p>
  <p>The latter part of the file is the date of the file. (For example <code>dailyReport_08262011.txt</code>, <code>dailyReport_08232011.txt</code>)</p>
  <p>I want to delete these files using a Java procedure. (I could go for a shell script and add it a job in the crontab but the application is meant to used by laymen).</p>
  <p>I can delete a single file using something like this:</p>
  <pre><code>try{
      File f=new File(&quot;dailyReport_08232011.txt&quot;);
      f.delete();
  }
  catch(Exception e){ 
      System.out.println(e);
  }
  </code></pre>
  <p>but can I delete the files having a certain prefix? (e.g. <code>dailyReport08</code> for the 8th month) I could easily do that in shell script by using <code>rm -rf dailyReport08*.txt</code> .</p>
  <p>But <code>File f=new File(&quot;dailyReport_08*.txt&quot;);</code> doesnt work in Java (as expected).</p>
  <p>Now is anything similar possible in Java <strong>without running a loop</strong> that searches the directory for files?</p>
  <p>Can I achieve this using some special characters similar to <code>*</code> used in shell script?</p>