This content has been marked as final. Show 5 replies
The size of a directory is the amount of space the directory takes up on disk.
For this, just use File.length.
If you want the total size of all the files in the directory and any subdirectory you need to get the size of each file.directory under it.
Java works in accordance with the underlying OS. In Windows explorer the folder has no size while each file has a size. Perhaps thats why there is no method in Java to get fodler size. But when you right click a folder and view Properties you get the size. that should be implemented in Java through a method.
pkjsp wrote:... because Windows Explorer iterates over all the files (and files within child folders, recursively) and adds them up. It isn't built into the OS at all, and the java API would have to do the same thing Explorer does if it were to want this feature.
... But when you right click a folder and view Properties you get the size ...