http如何在Java 8中通过文件系统类与外部文件系统连接?
我在OCP: Oracle Certified Professional Java SE 8 Programmer II Study Guide书中找到了以下使用http协议与外部文件系统建立连接的示例:
FileSystem fileSystem = FileSystems.getFileSystem(new URI("http://www.selikoff.net"));
Path path = fileSystem.getPath("duck.txt");
但当我运行这个示例时,我会收到运行时异常:
Exception in thread "main" java.nio.file.ProviderNotFoundException: Provider "http" not found
有人能解释这个例外的原因吗
如何运行这个示例,使用FileSystem类正确连接外部文件系统
非常感谢您的帮助
# 1 楼答案
看起来像NIO。API并没有试图规定我们应该如何引用外部文件系统。对于本地系统,它的行为类似于旧的API,但对于外部资源,我认为开发人员必须创建自己的定制提供者,以满足他们的需要
这里有一个起点:Developing A Custom File System Provider.