Page 1 of 1

Java: Get Directory -Größe - Fehlanpassung mit DU

Posted: 25 Feb 2025, 22:24
by Anonymous
Ich versuche, die Größe eines Verzeichnisses in Java herauszufinden. Ich überprüfe es von Linux Bash.

Code: Select all

commons-io
commons-io
2.18.0

Java

Code: Select all

Path p = Path.of ("mydir");
long sz = FileUtils.sizeOf (p.toFile ());
Konsole
du -sch mydir
< /code>
Du gibt mir 3.0m, aber Java sagt mir 2168168 (das ist etwas mehr als 2 MB). < /p>
Wo ist das Problem hier? /P>