Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the number of files in a folder in java [duplicate]

Tags:

java

browser

file

I'm making a basic file browser and want to know how to get the number of files in any given directory (necessary for the for loops that add the files to the tree and table)

like image 251
Ky. Avatar asked Dec 06 '10 03:12

Ky.


1 Answers

From javadocs:

  • http://download.oracle.com/javase/6/docs/api/java/io/File.html

You can use:

new File("/path/to/folder").listFiles().length
like image 101
icyrock.com Avatar answered Nov 16 '22 00:11

icyrock.com



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!