Errata: Change
File f = new File("a,txt");
to
File f = new File("a.txt");
. After that when you write that statement, the object will start referring to a PATH which has a.txt in the end. It is not necessary that the file a.txt is present. But when you call
f.createNewFile()
then if a.txt doesn't exists, it will be created. So you can be sure that after call to createNewFile, the object f refers to a file a.txt...