Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

CHAPTER 2: Metadata File Attributes > Determining Views Supported by a Particul...

Determining Views Supported by a Particular File System

Before you attempt to access a view's attributes, make sure that your file system supports the corresponding view. NIO.2 lets you either view the entire list of supported views by name or check if a file store—represented by the FileStore class that maps any type of store, such as partitions, devices, volumes, and so on—supports a particular view.

Once you obtain access to the default file system—by calling the FileSystems.getDefault() method—you can easily iterate over the supported views returned by the FileSystem.supportedFileAttributeViews() method. The following code snippet shows how to do this:

import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.util.Set;

FileSystem fs = FileSystems.getDefault();        
Set<String> views = fs.supportedFileAttributeViews();
        
for (String view : views) {
      System.out.println(view);
}

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint