Java Disk Free Space Get getFreeSpaceOnPartition(File f)

Here you can find the source of getFreeSpaceOnPartition(File f)

Description

Returns the free space on the partion where the specified file is located

License

Open Source License

Parameter

Parameter Description
f the file

Return

the free space (byte)

Declaration

public static long getFreeSpaceOnPartition(File f) 

Method Source Code


//package com.java2s;
import java.io.*;

public class Main {
    /**/*from w  w w. j a  v  a2 s .  com*/
     * Returns the free space on the partion where the specified file is located
     *
     * @param f the file
     * @return the free space (byte)
     */
    public static long getFreeSpaceOnPartition(File f) {
        // TODO sometimes f.getUsableSpace() returned 0 and we had to use
        // the filesystem root to determine free space. is it safe now to
        // directly use f.getUsableSpace() ?
        return f.getUsableSpace();
    }
}

Related

  1. getFreeSpace(File directory)
  2. getFreeSpace(File file)
  3. getFreeSpace(String dir)
  4. getFreeSpace(String pathname)
  5. getTreeSize(File root)
  6. getTreeSize(File root)
  7. getUnixFreeSpace(String pathname)