集册 Java实例教程 将supportsFileAttributeView方法与类参数一起使用

将supportsFileAttributeView方法与类参数一起使用

欢马劈雪     最近更新时间:2020-01-02 10:19:05

469
通过类参数使用supportsFileAttributeView方法

import java.io.IOException;//来自 nowjava - 时  代  Java

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.AclFileAttributeView;

import java.nio.file.attribute.BasicFileAttributeView;

import java.nio.file.attribute.DosFileAttributeView;

import java.nio.file.attribute.FileAttributeView;

import java.nio.file.attribute.FileOwnerAttributeView;

import java.nio.file.attribute.PosixFileAttributeView;

import java.nio.file.attribute.UserDefinedFileAttributeView;


public class Main {

  public static void main(String[] args) {

    try {


      Path path = Paths.get("C:/home/docs/users.txt");
      /*
       from NowJava.com - 时  代  Java 
      */

      FileStore fileStore = Files.getFileStore(path);

      System.out.println("FileAttributeView supported: "

          + fileStore.supportsFileAttributeView(FileAttributeView.class));

      System.out.println("BasicFileAttributeView supported: "

          + fileStore.supportsFileAttributeView(BasicFileAttributeView.class));

      System.out.println("FileOwnerAttributeView supported: "

          + fileStore.supportsFileAttributeView(FileOwnerAttributeView.class));

      System.out.println("AclFileAttributeView supported: "

          + fileStore.supportsFileAttributeView(AclFileAttributeView.class));

      System.out.println("PosixFileAttributeView supported: "

          + fileStore.supportsFileAttributeView(PosixFileAttributeView.class));

      System.out.println("UserDefinedFileAttributeView supported: "

          + fileStore

              .suppor
展开阅读全文