tags:

views:

30

answers:

3

According to the File.listFiles javadoc the method

Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.

I know that I am using a directory, but have received a null result, so an I/O error must've appeared. I'm very much interested in what the error was.

How can I retrieve the error message/code when such a null result is returned?

+3  A: 
polygenelubricants
+1  A: 

From what I see from an implementation of File, it will return null if

  • the file is not a directory or
  • the file does not exist or
  • the directory is read-protected.

No evidence of a 'hidden' IOException although an I/O Error might occur in the native code.

Andreas_D
The javadoc says nothing about an I/O Exception, but that an I/O error occurs. That suggests that there is no native error -> Exception translation.
Robert Munteanu
A: 

How likely is it that an I/O error occurs every time you try to test your code? I would say that there is a problem with the directory not existing or you not having the right permissions.

BobTurbo
I just said that I know the directory exists. It's been running in production for months, and now it failed _just once_. It has been running fine ever since.
Robert Munteanu