GeeCON Prague 2014*
The moose likes Java in General and the fly likes what is the maximum size?  File [] files = dir.listFiles() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "what is the maximum size?  File [] files = dir.listFiles() " Watch "what is the maximum size?  File [] files = dir.listFiles() " New topic
Author

what is the maximum size? File [] files = dir.listFiles()

Jennifer McAllister
Greenhorn

Joined: Jan 14, 2003
Posts: 2
I have over 1000 files and when my program fails around this line:
File [] files = dir.listFiles();
It works with a little over 500 files. Is there a maximum size it can handle? each file is about 4k.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
I don't believe there's any max as far as Java is concerned, other than Integer.MAX_VALUE which limits the size of any array. Perhaps there's some platform limitation? What exactly happens when this method fails? Is an exception thrown? What if you list files outisde Java, using OS commands - can you list all 1000 files? You can probably list the files to a new file - e.g. (for Windows)
(Don't put the new output file in the same directory you're trying to list - that just confuses things.) Once you have the output in a file, you can see how many lines there are, and check for any other anomalies.


"I'm not back." - Bill Harding, Twister
 
GeeCON Prague 2014
 
subject: what is the maximum size? File [] files = dir.listFiles()