Test.java Source code

Java tutorial

Introduction

Here is the source code for Test.java

Source

import java.nio.file.FileStore;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;

public class Test {
    static final long kiloByte = 1024;

    public static void main(String[] args) throws Exception {
        FileSystem fileSystem = FileSystems.getDefault();

        for (FileStore fileStore : fileSystem.getFileStores()) {
            long totalSpace = fileStore.getTotalSpace() / kiloByte;
            long usedSpace = (fileStore.getTotalSpace() - fileStore.getUnallocatedSpace()) / kiloByte;
            long usableSpace = fileStore.getUsableSpace() / kiloByte;
            String name = fileStore.name();
            String type = fileStore.type();
            boolean readOnly = fileStore.isReadOnly();
        }
    }
}