title: Using the FileWriter with a full path
body: <p>I specified the full path of the file location when I created a FileWriter, but I did not see the file being created. I also did not get any error during file creation.</p>
  
  <p>Here's a snippet of my code:</p>
  
  <pre><code>public void writeToFile(String fullpath, String contents) {
      File file = new File(fullpath, "contents.txt");
      if (!file.exists()) {
          try {
              file.createNewFile();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
      try {
          BufferedWriter bw = new BufferedWriter(new FileWriter(file.getAbsoluteFile()));
          bw.write(contents);
          bw.close();
      } catch (IOException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>fullpath is <code>"D:/codes/sources/logs/../../bin/logs"</code>.
  I have searched my whole directory, but I cannot find the file anywhere.
  If I specify just the filename only [File file = new File("contents.txt");] , it is able to save the contents of the file, but it is not placed on my preferred location.</p>
  
  <p>How can I save the file content to a preferred location?</p>
  
  <p>UPDATE:
  I printed the full path using file.getAbsolutePath(), and I am getting the correct directory path. [D:\codes\sources\logs....\bin\logs\contents.txt] But when I look for the file in directory, I cannot find it there.</p>