This code is the source of the problem:
Sorry - but I don't see how that is even possible.
The code you posted does not even refer to the 'document' instance variable except to set it.
More likely there is code that you did NOT post that is causing the problem.
Post actual, complete, sample code that demonstrates the problem you say you are having.
If that code is REALLY the source of the problem you should be able to provide a sample class file that has NOTHING but that code and the missing import statements for the classes you are using.
I would expect another error to be possible from this code, a FileNotFoundException if you can't read that file (or possibly some security related exception if you have no read or write access to its location).
An NPE as rp0248 points out won't happen until later, trying to use that Document instance if you tried running this code, ignored that earlier exception, and just assumed that the document had now been initialised.