aspose file tools*
The moose likes Java in General and the fly likes Cant load files into array using listFiles. I think it's an eclipse problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Cant load files into array using listFiles. I think it Watch "Cant load files into array using listFiles. I think it New topic
Author

Cant load files into array using listFiles. I think it's an eclipse problem

Thang Pham
Ranch Hand

Joined: Jan 21, 2009
Posts: 35
This piece of code work on my ubuntu box, when I import it onto Eclipse on my window, it complains:

This is the line that it complains

fileImg return null after this line, mean either directory is not exist or there is some IO error. So I print out the path of "dir" which is the folder "image" in the same directory as my source code, and I get a valid path. So the directory do exist. "dir" reference the directory. So what could be the problem? Here is my code
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18651
    
    8

Well, the API documentation has this to say about the listFiles method:
Returns null if this abstract pathname does not denote a directory

So that's what is happening. I suspect you are making some assumptions about that so-called directory which aren't correct.
Thang Pham
Ranch Hand

Joined: Jan 21, 2009
Posts: 35
Sorry, it was a stupid mistake, i have the folder in the wrong location. I have the source file and image folder inside src folder, you know I want them to be in the same level. However, Eclipse does not think current level is where the source file is, to Eclipse, current level is the same level as src folder, where the project file is. That why it could not see the "image folder"
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18651
    
    8

Yes... if you hadn't mentioned that you were a Unix user, I would have mentioned the possibility of differences in the current working directory. But Unix users generally know that concept. Anyway, you got it fixed so that's the main thing.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cant load files into array using listFiles. I think it's an eclipse problem