Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File.getUsableSpace() does not return the same value as the "df" command in Linux

Tags:

java

linux

I want to print the number of bytes of all free space of a partition using File.getUsuableSpace() but it returns another value than the df command (in Linux) does.

It does not differ that much, but it differs in several megabytes.

What could be the case?

like image 349
Rox Avatar asked Aug 31 '26 06:08

Rox


1 Answers

Is the file that your File instance represents on the same partition as the one you're running df on?

From the docs: "Returns the number of bytes available to this virtual machine on the partition named by this abstract pathname"

Emphasis is mine.

like image 162
daveb Avatar answered Sep 05 '26 09:09

daveb



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!