Java FileStore check if file attribute support DosFileAttributeView

Description

Java FileStore check if file attribute support DosFileAttributeView

import java.io.IOException;
import java.nio.file.FileStore;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.DosFileAttributeView;
import java.nio.file.attribute.FileAttributeView;

public class Main {
  public static void main(String[] args) {
    Path path = Paths.get("C:/Java_dev");
    try {//from  w w  w  .  j  a va 2 s . c  om
      FileStore fs = Files.getFileStore(path);
      Class<? extends FileAttributeView> attribClass = DosFileAttributeView.class;
      // Check if the file attribute view is supported
      boolean supported = fs.supportsFileAttributeView(attribClass);

      System.out.format("%s is supported: %s%n", attribClass.getSimpleName(), supported);

    } catch (IOException ex) {
      ex.printStackTrace();
    }
  }
}



PreviousNext

Related