3

I found the following example of establishing connection with external file system using http protocol in OCP: Oracle Certified Professional Java SE 8 Programmer II Study Guide book:

FileSystem fileSystem = FileSystems.getFileSystem(new URI("http://www.selikoff.net"));
Path path = fileSystem.getPath("duck.txt");

But when I'm running this example, I receive runtime exception:

Exception in thread "main" java.nio.file.ProviderNotFoundException: Provider "http" not found

Can anyone explain the reason of this exception?
How can I run this example, to connect with external file system properly using FileSystem class?

Any help highly appreciated.

Michał Szewczyk
  • 7,540
  • 8
  • 35
  • 47
  • I can’t read that specific page of the linked book, but I guess, this is only a hypothetical example, not an example that is supposed to work out of the box. There is no pre-installed `http` file system. – Holger Jan 16 '17 at 09:32

1 Answers1

1

It looks like the NIO.2 API doesn't try to dictate how we should reference external file systems. For the local system, it behaves like the older API, but for external resources, I think the developers have to create their own custom provider fit for the purpose they need.

There is a starting point here: Developing A Custom File System Provider.

Tesfaye B.
  • 11
  • 2