How to use PrintWriter and File classes in Java?

If the directory doesn’t exist you need to create it. Java won’t create it by itself since the File class is just a link to an entity that can also not exist at all. As you stated the error is that the file cannot be created. If you read the documentation of PrintWriter constructor you can see … Read more

PrintWriter append method not appending

The fact that PrintWriter‘s method is called append() doesn’t mean that it changes mode of the file being opened. You need to open file in append mode as well: Also note that file will be written in system default encoding. It’s not always desired and may cause interoperability problems, you may want to specify file encoding explicitly.

error code: 523