title: How to use PrintWriter and File classes in Java?
body: <p>I am trying to understand PrintWriter for a small program I'm making, and I cant seem to get java to make the file and then write on it. When I execute the program below it gives me a Filenotfoundexeption error on line 9. It also fails to make the file in the directory that I specified. I am new to this so please try and keep the answers simple. I am using Eclipse.</p>
  
  <pre><code>import java.io.PrintWriter;
  import java.io.File;
  
  public class Testing {
  
    public static void main(String[] args) {
  
      File file = new File ("C:/Users/Me/Desktop/directory/file.txt");
      PrintWriter printWriter = new PrintWriter ("file.txt");
      printWriter.println ("hello");
      printWriter.close ();       
    }
  }
  </code></pre>