title: Unable to delete files using Java
body: <p>I have written the following code to merge and delete the source files,but somehow the source files are not getting deleted.Can any one please throw some light on what i 'm missing here.</p>
  
  <pre><code>    public void doDelete(List&lt;String&gt; dID)throws  IOException {
  
          String DID=null;
  
          try{
              for( ListIterator&lt;String&gt; iterator = dID.listIterator(); iterator.hasNext();)
              {
  
                  DID= (String) iterator.next();
  
                  System.out.println("Deleting PDF" +DID);
                  File f =new File("E:\\TestFolder"+ "\\" +DID+".pdf");
                   if (!f.exists()) {
                          System.err.println("File " + f
                              + " not present to begin with!");
                          return;
                        }
                  System.out.println(f.length());
                  System.out.println(f.getAbsolutePath());
                  boolean success = f.delete();
                  if (!success){
                      System.out.println("Deletion failed.");               
                  }else{
                      System.out.println("File deleted."+DID);
                  }
              }
          }catch (Exception e) {
              // TODO: handle exception
              e.printStackTrace();             
          }
      }   
  }
  </code></pre>