Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes Beginning Java and the fly likes File-listFiles() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "File-listFiles()" Watch "File-listFiles()" New topic
Author

File-listFiles()

Alec Porter
Greenhorn

Joined: Sep 05, 2010
Posts: 29
So I'm trying to get the class files by calling listFiles()



For the parent file I'm getting my class directory which is what I want.



but it's returning null. On the java API it says for that method that "If this abstract pathname does not denote a directory, then this method returns null. " Event though I know it has the correct directory I need and there are files in it. So why does this happen?
Andrey Kozhanov
Ranch Hand

Joined: Mar 12, 2010
Posts: 79
I believe your problem is in URL-encoded name of the directory you want. Replacing %20 with spaces should solve the problem.
Alec Porter
Greenhorn

Joined: Sep 05, 2010
Posts: 29
Why is it doing that and how do I fix it?
Andrey Kozhanov
Ranch Hand

Joined: Mar 12, 2010
Posts: 79
This is just my suggestion, so no idea why this is happening. But to check whether i am right is rather easy:
Alec Porter
Greenhorn

Joined: Sep 05, 2010
Posts: 29
Well that fixed it. Thanks, not sure why it does that though.
 
Have you tried LearnNowOnline? http://www.learnnowonline.com/
 
subject: File-listFiles()