我一直使用NIO2文件路径来访问本地文件系统资源。但是,当我尝试对非本地文件系统使用相同的API时,我得到了以下异常:
Exception in thread "main" java.nio.file.FileSystemNotFoundException:
Provider "http" not installed. Code snippet can be found below
Path toFileSystem= Paths.get(new URI("http://www.wiley.com"));我想确认一下,是否有一种方法可以将http添加到FileSystemProvider?或者,在通过NIO2应用程序接口访问非本地模式时,有没有好的指南可供我遵循?
发布于 2018-01-29 03:04:13
我不认为std库中有HTTP文件系统提供程序。这是因为在另一端有不同的方法来构建“文件系统”,并且没有合理的默认设置。
这个链接以相当全面的方式解释了NIO的东西:https://docs.oracle.com/javase/tutorial/essential/io/fileio.html。
您实际上正确地构造了这个Path,但问题是您没有注册到http方案的FileSystemProvider。
好消息是你可以自己做:https://docs.oracle.com/javase/7/docs/technotes/guides/io/fsp/filesystemprovider.html
https://stackoverflow.com/questions/48490014
复制相似问题