Get free space, total space, usable space
long getFreeSpace()
- Returns the number of unallocated bytes in the partition named by this abstract path name.
long getTotalSpace()
- Returns the size of the partition named by this abstract pathname.
long getUsableSpace()
- Returns the number of bytes available to this virtual machine on the partition named by this abstract pathname.
import java.io.File;
public class Main {
public static void main(String[] args) {
File aFile = new File("c:/");
System.out.println(aFile.getFreeSpace());
System.out.println(aFile.getTotalSpace());
System.out.println(aFile.getUsableSpace());
}
}
The output:
12283260928
79990812672
12283260928
Home
Java Book
File Stream
Java Book
File Stream
File:
- File
- Constants from File class
- Create file object
- Is it executable, readable or writable
- Compare two file path
- Create a file
- Delete a file
- Is it a file or a directory
- Whether the file or directory denoted by this abstract pathname exists
- Whether this abstract pathname is absolute
- Is this file hidden
- Get the file last modified time
- Get the file size
- Get file path and name
- Get free space, total space, usable space
- Get parent file
- Return file in a directory
- The file system roots
- Create new directories
- Rename file
- Change to executable, readable, writable
- Change last-modified time
- Get string representation of a file location
- Convert file location to URI and URL