Well, the mkdir() method and the createNewFile() method both return booleans which tell you whether the requested action was successful. But you are ignoring that information. Likewise most of the methods in the PrintWriter class ignore exceptions; there's a checkError() method which you could call to find out if there were any exceptions. But you aren't doing that either.
However the PrintWriter constructor which you used will throw an exception if there's a problem with finding or creating the file you asked it to use. Do you have code elsewhere which handles that exception? Or is there a stack trace which you are ignoring?
Since your named your class as file which is same as class File provided by java located in package "java.io". You can specify fully qualified name " java.io.File" otherwise compiler will think that you are trying to use your own File class.
I hope this helps.