Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Thang Pham
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20958
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20958
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic