title: Java : Creating Files, but Access Denied
body: <p>Yes, I did attempt googling and searching through StackOverflow, however, I was unable to come up with an answer, as I am still new to Java.</p>
  
  <p>Currently I am attempting to write data to a file, all I have as of now is:</p>
  
  <pre><code>private static void setup() throws IOException {
  
      String username = System.getProperty("user.name");
  
      File file = new File("C:\\Users\\" + username + "\\Documents\\", "data.txt");
      if(!file.exists()) {
          file.mkdir();
      }
      BufferedWriter out = new BufferedWriter(new FileWriter(file));
      out.write("Bacon");
      out.close();
  
  }
  </code></pre>
  
  <p>However upon running the program, I receive an error regarding File Permissions, reading: <code>Exception in thread "main" java.io.FileNotFoundException: C:\Users\cvi7\Documents\data.txt (Access is denied)</code></p>
  
  <p>Now I see, <code>java.io.FileNotFoundException</code>, however, how would I create the file if the <code>new File()</code> doesn't? I am assuming it probably has to do with permissions however in the case my brain had a fail, I would hope to hear about this too.</p>