FileSystem getFileStores() Method in Java with Examples Last Updated : 10 Sep, 2019 Comments Improve Suggest changes Like Article Like Report The getFileStores() method of java.nio.file.FileSystem is used to return an iterable of FileStore object to iterate over the underlying file stores. The elements contained by the returned iterator are the FileStores for this file system. When an input-output error occurs, because of the inaccessibility to a file store, then it is not returned by the iterator. Syntax: public abstract Iterable<FileStore> getFileStores() Parameters: This method does not accept anything. Return value: This method returns an object to iterate over the backing file stores. Below programs illustrate getFileStores() method: Program 1: Java // Java program to demonstrate // java.nio.file.FileSystem.getFileStores() method import java.nio.file.*; import java.util.Iterator; public class GFG { public static void main(String[] args) { // create object of Path Path path = Paths.get("C:\\Users\\" + "asingh.one\\Documents"); // get FileSystem object FileSystem fs = path.getFileSystem(); // apply getFileStores() methods Iterable<FileStore> it = fs.getFileStores(); // print all FileStore contains by this system Iterator<FileStore> iterator = it.iterator(); System.out.println("FileStrores are:\n"); while (iterator.hasNext()) { System.out.println(iterator.next()); } } } Output: Program 2: Java // Java program to demonstrate // java.nio.file.FileSystem.getFileStores() method import java.nio.file.*; import java.util.Iterator; public class GFG { public static void main(String[] args) { // create object of Path Path path = Paths.get("D:\\eclipse"); // get FileSystem object FileSystem fs = path.getFileSystem(); // apply getFileStores() methods Iterable<FileStore> it = fs.getFileStores(); // print all FileStore contains by this system Iterator<FileStore> iterator = it.iterator(); System.out.println("FileStores on system are:\n"); while (iterator.hasNext()) { System.out.println(iterator.next()); } } } Output: References: https://docs.oracle.com/javase/10/docs/api/java/nio/file/FileSystem.html#getFileStores() Comment More infoAdvertise with us Next Article FileSystem getFileStores() Method in Java with Examples A AmanSingh2210 Follow Improve Article Tags : Java Java-Functions java.nio.file package Practice Tags : Java Similar Reads Files getFileStore() method in Java with Examples getFileStore() method of java.nio.file.Files help us to return the FileStore object which represents the file store where a file is located. Once you get a reference to the FileStore you can apply filestore type of operation to get information of filestore. Syntax: public static FileStore getFileSto 2 min read FileSystem getRootDirectories() method in Java with Examples The getRootDirectories() method of a FileSystem class is used to return an Iterator object to iterate over the paths of the root directories for this File System. A file system is composed of a number of distinct file hierarchies, each with its own top-level root directory and each element in the re 2 min read FileSystem getSeparator() method in Java with Examples The getSeparator() method of a FileSystem class is used to return the name separator for this file system as a string. The name separator is used to separate names in a path string. In the case of the default provider, this method returns the same separator as String.Syntax: public abstract String g 2 min read FileSystem isOpen() method in Java with Examples The isOpen() method of a FileSystem class is used to return true if file system is open. This method is very helpful to know filesystem is open or not. File systems created by the default provider are always open. Syntax: public abstract boolean isOpen() Parameters: This method accepts nothing. Retu 2 min read FileStore getUsableSpace() method in Java with Examples The getUsableSpace() method of a FileStore class is used to return the number of bytes available to this Java virtual machine on the file store. This method is useful to check free space. This method returns the available usable space as a long value. Syntax: public abstract long getUsableSpace() th 2 min read Like