集册 Java实例教程 是否读取文件系统

是否读取文件系统

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

712
文件系统是只读的还是提供者是谁

import java.io.IOException;
/**来自 
 N o w  J a v a  .   c o m**/

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());
    /**
     from
    * nowjava 
    **/


    Iterable<Path> rootDirectories = fileSystem.getRootDirectories();

    System.out.println();

    System.out.println("Root Directories");

    for (Path path : rootDirectories) {

      System.out.println(path);

    }


    Iterable<FileStore> fileStores = fil
展开阅读全文