This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
You need to be performing you testing in a main method, I think that is probably why you are getting the null pointer exception. Also you need to import the Java File.IO class, this enables you to create new files.
"If the facts don't fit the theory, get new facts" --Albert Einstein
The code you posted won't even compile: as requested, please post the *actual* code that's causing a problem. And when reporting an exception, post some way of determining what code is actually causing the exception, because you won't get an NPE from the line you indicate.