Java Disk Free Space Get getFreeSpace(File file)

Here you can find the source of getFreeSpace(File file)

Description

get Free Space

License

Apache License

Return

free space available on the partition for the specified file

Declaration

public static long getFreeSpace(File file) 

Method Source Code


//package com.java2s;
/*//  w w w.ja va  2s.  c  om
 *  Copyright Gergely Nagy <greg@webhejj.hu>
 *
 *  Licensed under the Apache License, Version 2.0; 
 *  you may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 */

import java.io.File;

public class Main {
    /** @return free space available on the partition for the specified file */
    public static long getFreeSpace(File file) {

        long free = file.getFreeSpace();
        while (free == 0) {
            file = file.getParentFile();
        }
        return free;
    }
}

Related

  1. getFreeSpace(File directory)
  2. getFreeSpace(String dir)
  3. getFreeSpace(String pathname)
  4. getFreeSpaceOnPartition(File f)
  5. getTreeSize(File root)