Getting FileStore information : FileStore « JDK 7 « Java






Getting FileStore information

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();
    }
  }
}

 








Related examples in the same category

1.Check for the supported attribute