title: Cannot delete folder using Java
body: <p>I am trying to delete a folder which has only files but no sub folders without success.</p>
  
  <h2>Code:</h2>
  
  <pre><code>File rowFolder = new File(folderPath);
  String[] files = rowFolder.list();
  for (String file : files){
      File deleteFile = new File(file);
      System.out.println("deleting file -"+deleteFile.getName());
      deleteFile.delete();
  }
  System.out.println("deleting folder -"+rowFolder.getName());
  rowFolder.delete();
  </code></pre>
  
  <h2> Output:</h2>
  
  <pre><code>deleting file -testing.pdf
  deleting file -app_json.json
  deleting file -photo.jpg
  deleting folder -bundle_folder
  </code></pre>
  
  <p>The code doesn't delete any folder nor any file. Why is that?</p>