File: getTotalSpace() : File « « Java by API

File: getTotalSpace()



public class Main {

  public static void main(String[] args) {
    File file = new File("C:");
    long totalSpace = file.getTotalSpace();
    System.out.println("Total space on " + file + " = " + totalSpace + "bytes");

    // Check the free space in C:
    long freeSpace = file.getFreeSpace();
    System.out.println("Free space on " + file + " = " + freeSpace + "bytes");


Related examples in the same category

3.File: separatorChar File(String name) File(URI uri) File(String parent, String child)
7.File: canRead()
8.File: canWrite()
9.File: createNewFile()
10.File: createTempFile(String prefix, String suffix)
11.File: delete()
12.File: deleteOnExit()
13.File: exists()
14.File: getAbsoluteFile()
15.File: getAbsolutePath()
16.File: getCanonicalPath()
17.File: getFreeSpace()
18.File: getName()
19.File: getParent()
20.File: getParentFile()
21.File: getPath()
22.File: getUsableSpace()
23.File: isAbsolute()
24.File: isDirectory()
25.File: isFile()
26.File: listFiles()
27.File: isHidden()
28.File: lastModified()
29.File: length()
30.File: list()
31.File: listFiles(FilenameFilter filter)
32.File: listRoots()
33.File: mkdir()
34.File: mkdirs() (Creates a directory including any parent directories)
35.File: renameTo(File newFile)
36.File: setLastModified(long time)
37.File: setReadOnly()
38.File: setWritable(boolean writable)
39.File: toURI()
40.File: toURL()