问题描述
我使用的是 Apache Commons VFS 2.7.0 是否可以使用 VFS 访问存档内的存档内的文件?
我有一个 tar.bz2 文件,其中包含 tar.gz 文件,如下所示:
archive.tar.bz2
|
-archive2.tar.gz
|
-f1.html
-f2.html
-archive2.tar.gz
|
-file3.html
-file4.html
我正在尝试访问 html 文件。我可以用 VFS 做到这一点吗?
这是我尝试过的:
void testVFS() throws Exception {
File dir = new File("/");
File file = new File(dir.getAbsolutePath() + "/archive.tar.bz2");
FileSystemManager fsManager = VFS.getManager();
System.out.println("tbz2:" + file.toURI());
FileObject archive = fsManager.resolveFile("tbz2:" + file.toURI());
// List the children of the archive file
FileObject[] children = archive.getChildren();
System.out.println("Children of " + archive.getName().getURI()+" are ");
for (FileObject child : children) {
System.out.println("Child: " + child.getURI());
FileObject fo = archive.getFileSystem().getFileSystemManager().resolveFile("tgz:" + child.getPath()); // <-- throws FileSystemNotFoundException
for (FileObject gc : fo.getChildren()) {
System.out.println("Grand child: " + gc.getURI().toString());
}
}
}
产生输出
tbz2:file:/C:/archive.tar.bz2
Child: tbz2:file:///C:/archive.tar.bz2!/archive2.tar.gz
java.nio.file.FileSystemNotFoundException: Provider "tbz2" not installed....
我尝试了其他一些方法,包括尝试以“tgz:tbz2:file:/C:/archive.tar.bz2!archive.tar.gz”的形式访问内部文件,但遇到了类似的异常。
如何使用 VFS 访问这些文件?任何帮助将不胜感激,即使是“你不能用 Commons VFS2 做到这一点”
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)