Please look through code below:
// A.class File file = new File(\"blah.txt\"); FileWriter fileWriter = new FileWriter(file); PrintWriter printWriter = new P
I think that the reason behind using PrintWriter is already mentioned above but one of the important reason is you an pass a file object directly to the PrintWriter constructor which makes it easy to use it.
File file=new File(“newfile.txt”); PrintWriter pw=new PrintWriter(file);