listFiles() and use the length of the returned array?
See the API docs for File.
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
How do you normally use an array?
String[] files = file.listFiles();
int numFiles = files.length;
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
Also note that directories will also be included and can be discerned with file.isDirectory(). If you need to include file counts from subdirectories, you'll need to do the recursion yourself.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
You can count them recursively the same way you determined the total size. I assume you don't want to include directories in that count.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847