Java directory size on disk?

java

Solution

`du` finds this information by recursing through the entire directory tree and adding the sizes of all files it finds. (After rounding each file size up to an allocation unit I think, and how it finds out what the allocation unit is I don't know).

You will have to do likewise, or spawn an external `du` process to do it for you.

Problem

I'm currently using the apache-commons FileUtils.sizeOfDirectory(File file) method to get the size of a directory. What I actually need tough is the size of the directory on disk, the one displayed by the du utility under Unix, just to be clear. Is it possible to get this information in Java?

Original source

Related problems