Probably because you never initialized fileobj to be an actual File object?
By the way, do not trust that list() will return a valid array. From the API:
Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.
If your directory cannot be read for some reason, such as file level permissions that block you from opening the folder, it will return null without a doubt.
The same goes for listFiles().