我正在尝试创建一个FileSystem对象来保存ext2文件系统.我URI似乎无效,给我一个路径组件应该是'/'运行时错误.
我正在使用Windows并在Eclipse中使用我的项目,其中包含一个名为"fs"的子目录,用于保存文件系统映像.
我的代码......
URI uri = URI.create("file:/C:/Users/Rosetta/workspace/filesystemProject/fs/ext2");
/* uri holds the path to the ext2 file system itself */
try {
FileSystem ext2fs = FileSystems.newFileSystem(uri, null);
} catch (IOException ioe) {
/* ... code */
}
Run Code Online (Sandbox Code Playgroud)
我已经将文件系统作为File对象加载并使用该getURI方法来确保我URI与实际相同URI,并且确实如此.
如何加载文件系统?
编辑:
下面的堆栈跟踪
Exception in thread "main" java.lang.IllegalArgumentException: Path component should be '/'
at sun.nio.fs.WindowsFileSystemProvider.checkUri(Unknown Source)
at sun.nio.fs.WindowsFileSystemProvider.newFileSystem(Unknown Source)
at java.nio.file.FileSystems.newFileSystem(Unknown Source)
at java.nio.file.FileSystems.newFileSystem(Unknown Source)
Run Code Online (Sandbox Code Playgroud)