java.nio.file.FileSystem class in java
java.nio.file.FileSystem class provides an interface to a file system. The file system acts as a factory for creating different objects like Path, PathMatcher, UserPrincipalLookupService, and WatchService. This object help to access the files and other objects in the file system.
Syntax: Class declaration
public abstract class FileSystem extends Object implements Closeable
The constructor of this class is as follows:
Constructor Description FileSystem() Creates a new object of FileSystem class
Methods of this class are as follows:
Method Description close() Closes this file system that has been opened. getFileStores() Returns an iterable object, which is used to iterate over the underlying file stores. getPath(String first, String… more) Converts given string to a Path or combines a given sequence of strings to form a Path. getPathMatcher(String syntaxAndPattern) Returns a PathMatcher object which is used to perform match operations on the Path objects. getRootDirectories() Returns an iterable object, which is used to iterate over the root directories. getSeparator() Returns string representation of the name separator. getUserPrincipalLookupService() Returns the UserPrincipalLookupService object for this file system. It is an optional operation. isOpen() Used to check whether this file system is open or not. isReadOnly() Used to check whether this file system allows read-only access to its file stores or not. newWatchService() Returns a new WatchService object. provider() Returns the provider that created this file system. supportedFileAttributeViews() Returns the set consisting of the names of the file attribute views supported by this file system.
File System created successfully Underlying file stores of this FileSystem : / (/dev/disk1s1) /dev (devfs) /private/var/vm (/dev/disk1s4) /net (map -hosts) /home (map auto_home) Root directories of this FileSystem : /
FileSystem created successfully File system is open File system is not Read-only Separator: / Hashcode: 929338653 Provider: sun.nio.fs.MacOSXFileSystemProvider@4b1210ee
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.