Example usage for java.nio.file FileStore getUnallocatedSpace

List of usage examples for java.nio.file FileStore getUnallocatedSpace

Introduction

In this page you can find the example usage for java.nio.file FileStore getUnallocatedSpace.

Prototype

public abstract long getUnallocatedSpace() throws IOException;

Source Link

Document

Returns the number of unallocated bytes in the file store.

Usage

From source file:Main.java

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

    for (FileStore store : fileSystem.getFileStores()) {
        long total = store.getUnallocatedSpace() / 1024;
        System.out.println(total);
    }// w  w w  .j  ava 2  s .  com
}

From source file:Test.java

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();
    }/*from w  w  w  . j  av a  2s .c  o m*/
}

From source file:Main.java

public static void printDetails(FileStore store) {
    try {//from w w w  . j  av a2 s  .  c o  m
        String desc = store.toString();
        String type = store.type();
        long totalSpace = store.getTotalSpace();
        long unallocatedSpace = store.getUnallocatedSpace();
        long availableSpace = store.getUsableSpace();
        System.out.println(desc + ", Total: " + totalSpace + ",  Unallocated: " + unallocatedSpace
                + ",  Available: " + availableSpace);
    } catch (IOException e) {
        e.printStackTrace();
    }
}