title: File.exists not working in java
body: <p>This is the code I have written to delete a file if it already exists</p>
  
  <pre><code>public  void createFile(Map&lt;String, String&gt; map, String name) 
  {
      try
      {
          System.out.println("Creating new File...");
          File file = new File("./Analysis/files/master.csv");
          if (file.exists()) 
          {
              System.out.println("File Deleted...."+file.delete());
          }
          System.out.println("New File Created   "+file.createNewFile());
          FileWriter fw = new FileWriter(file, true);
          for (Map.Entry&lt;String, String&gt; entry : map.entrySet()) 
          {
              fw.write(entry.getKey());
              fw.write(",");
              fw.write(entry.getValue());
              fw.write("\n");
              fw.flush();
          }
          fw.close();
      }catch(IOException e)
      { 
          throw new BuildException(e.getMessage());
      }
  }
  </code></pre>
  
  <p>This file.exists is showing false for the file which already exists in that path so its not deleting that file and append the contents to that file.Any idea?</p>