1

I tried with File getFreeSpace() also which returns me 0. Is there any other way to do this?

Ashwin
  • 847
  • 1
  • 6
  • 5
  • http://publications.gbdirect.co.uk/c_book/, http://www.ubuntu.com/ and http://linux.die.net/man/2/statvfs should get you started – Matt Joiner Nov 11 '10 at 07:29

4 Answers4

0

How about the older org.apache.commons.io.FileSystemUtils?

jcomeau_ictx
  • 37,688
  • 6
  • 92
  • 107
0
try {

    double freeDiskSpace = org.apache.commons.io.FileSystemUtils.freeSpaceKb("/volume"); 
    double freeDiskSpaceGB = freeDiskSpace / 1024 / 1024;
    System.out.println("Free Disk Space (GB):" + freeDiskSpaceGB);

    } catch (IOException e) {
            e.printStackTrace();
    }
jmj
  • 237,923
  • 42
  • 401
  • 438
0

Try

System{" df -k | awk '{sum += $4 }i; END {print sum} '"};
James Anderson
  • 27,109
  • 7
  • 50
  • 78
0
public long getTotalSpace();
public long getFreeSpace();
public long getUsableSpace();

Each of these methods returns the requested size, in bytes, of the partition represented by the java.io.File or 0L if a partition cannot be obtained from the File object. Can you report your code?

mauretto
  • 3,183
  • 3
  • 27
  • 28