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.