Rox
Rox

Reputation: 2917

File.getUsableSpace() does not return the same value as the "df" command in 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?

Upvotes: 3

Views: 1891

Answers (2)

Hadeer Beden
Hadeer Beden

Reputation: 1

This will only give the available space, try getFreeSpace() will return the free space and not available to use space. This works in Java 1.6, for more information, look at the File class documentation.

Upvotes: 0

daveb
daveb

Reputation: 76181

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.

Upvotes: 2

Related Questions