Example usage for java.nio.file FileSystem getFileStores

List of usage examples for java.nio.file FileSystem getFileStores

Introduction

In this page you can find the example usage for java.nio.file FileSystem getFileStores.

Prototype

public abstract Iterable<FileStore> getFileStores();

Source Link

Document

Returns an object to iterate over the underlying file stores.

Usage

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 www  .j a  v a  2  s.co  m*/
}

From source file:Main.java

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

    Iterable<FileStore> fileStores = fileSystem.getFileStores();
    System.out.println();//from w ww.jav a  2  s.c  o m
    System.out.println("File Stores");
    for (FileStore fileStore : fileStores) {
        System.out.println(fileStore.name());
    }

}

From source file:Main.java

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

    System.out.println("Read-only file system: " + fs.isReadOnly());
    System.out.println("File name separator: " + fs.getSeparator());

    for (FileStore store : fs.getFileStores()) {
        printDetails(store);/* ww w  .  j  av a  2  s .c  o m*/
    }
    for (Path root : fs.getRootDirectories()) {
        System.out.println(root);
    }
}

From source file:Test.java

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

    System.out.println("Provider: " + provider.toString());
    System.out.println("Open: " + fileSystem.isOpen());
    System.out.println("Read Only: " + fileSystem.isReadOnly());

    Iterable<Path> rootDirectories = fileSystem.getRootDirectories();
    System.out.println();//  w  w w  .  j a  va  2  s  . c  o m
    System.out.println("Root Directories");
    for (Path path : rootDirectories) {
        System.out.println(path);
    }

    Iterable<FileStore> fileStores = fileSystem.getFileStores();
    System.out.println();
    System.out.println("File Stores");
    for (FileStore fileStore : fileStores) {
        System.out.println(fileStore.name());
    }
}