title: Java writing file - Access is denied
body: <p>I'm trying to write a file using netbeans to a path inside the project directory so that other people on other PC's don't get error messages when running the same project (unable to find C://user...) </p>
  
  <pre><code>try {
      File file = new File("producten.txt");
  
      if (!file.exists()) {
          file.createNewFile();
      }
  
      FileWriter fw = new FileWriter(file, false);
      BufferedWriter bw = new BufferedWriter(fw);
  
      for (int i = 0; i &lt; db.getNumberOfItems(); i++) {
          bw.write("example1" + "\t");
          bw.write("example1" + "\t");
          bw.write("\r\n");
      }
      bw.close();
  } catch (IOException e) { e.printStackTrace(); }
  </code></pre>
  
  <p>I'm getting the console error message:</p>
  
  <pre><code> Access is denied
  </code></pre>
  
  <p>When I use a absolute path directed to my desktop directory it works.</p>