Test a particular view on a file store by calling the FileStore.supportsFileAttributeView() method. - Java File Path IO

Java examples for File Path IO:File System

Introduction

The following code checks whether the basic view is supported by all the available file stores:

Demo Code

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

public class Main {
  public static void main(String[] args) {

    FileSystem fs = FileSystems.getDefault();
    for (FileStore store : fs.getFileStores()) {
      boolean supported = store
          .supportsFileAttributeView(BasicFileAttributeView.class);
      System.out.println(store.name() + " ---" + supported);
    }//from  w w w .  jav  a 2 s .  c  o m

  }
}

Result


Related Tutorials