Try by giving the exact path
PrintWriter output = new PrintWriter(new FileWriter("C:\\textfile.txt"))