Get folder size

前端 未结 8 1118
生来不讨喜
生来不讨喜 2020-12-30 06:27

Do you know how can I get the folder size in Java?

The length() method in the File class only works for files, using that method I always get a size of 0.

相关标签:
8条回答
  • 2020-12-30 07:07

    Use apache-commons-io, there's a FileUtils class with a sizeOfDirectory methods

    0 讨论(0)
  • 2020-12-30 07:07

    Folders generally have a very small "Size", you can think of them as an index.

    All the programs that return a "Size" for a folder actually iterate and add up the size of the files.

    0 讨论(0)
提交回复
热议问题