Whether the filesystem is read-only or who the provider is - Java File Path IO

Java examples for File Path IO:File System


Whether the filesystem is read-only or who the provider is

Demo Code

import java.io.IOException;
import java.nio.file.FileStore;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.spi.FileSystemProvider;

public class Main {

  public static void main(String[] args) throws IOException {

    FileSystem fileSystem = FileSystems.getDefault();
    FileSystemProvider provider = fileSystem.provider();

    System.out.println("Provider: " + provider.toString());
    System.out.println("Open: " + fileSystem.isOpen());
    System.out.println("Read Only: " + fileSystem.isReadOnly());

    Iterable<Path> rootDirectories = fileSystem.getRootDirectories();
    System.out.println();/*w w  w. j  a  v  a 2  s .co m*/
    System.out.println("Root Directories");
    for (Path path : rootDirectories) {

    Iterable<FileStore> fileStores = fileSystem.getFileStores();
    System.out.println("File Stores");
    for (FileStore fileStore : fileStores) {


Related Tutorials