Sunday 16 June 2019

NIO2: Get all the installed file system providers


‘FileSystemProvider.installedProviders()’ return all the installed file system providers. Usually two file system providers (file, jar) comes with jdk.

App.java
package com.sample.app;

import java.nio.file.spi.FileSystemProvider;
import java.util.List;


public class App {

 public static void main(String args[]) {
  List<FileSystemProvider> fileSystemProviders = FileSystemProvider.installedProviders();
  
  for(FileSystemProvider fileSystemProvider : fileSystemProviders) {
   System.out.println(fileSystemProvider.getScheme());
  }

 }
}

Output
file
jar

Previous                                                 Next                                                 Home

No comments:

Post a Comment