我有一个关于以下代码的问题:
TFile src = new TFile(this.getMellomStasjon());
TFile dst = new TFile(this.getZipFolder()+""+zipFile+".zip");
if(dst.isDirectory())
dst = new TFile(dst, src.getName());
TFile.cp_rp(src, dst, null);
TFile file = newNonArchiveFile(dst);
if(dst.isArchive())
TFile.umount(dst);我的目标是使用TrueZip将包含文件的目录放入ZIP存档中。问题是代码在本地运行,但不能在生产计算机上运行。在本地,我得到一个单独的ZIP文件,但在生产环境中,我得到一个文件夹,其中包含我试图放入存档(虚拟目录)中的文件。我必须使用TrueZip,因为我要归档超过4 4GB的内容。
有没有办法强制TrueZip创建存档而不是(虚拟)目录?
发布于 2011-10-02 04:43:09
它可能无法工作,因为模块TrueZIP驱动程序ZIP的JAR工件没有出现在运行时类路径上。
为了确保它是正确的,您可以通过设置自定义TArchiveDetector来使ZipDriver成为编译时依赖项。下面是一个示例:http://truezip.java.net/usecases/aff.html
您在此处显示的代码有问题。您可能应该将其修复为:
// Call this once at application startup to make the ZipDriver a compile time
// dependency.
TFile.setDefaultArchiveDetector(
new TArchiveDetector(
"zip",
new ZipDriver(IOPoolLocator.SINGLETON)));
// Here's the work.
TFile src = new TFile(this.getMellomStasjon());
TFile dst = new TFile(this.getZipFolder(), zipFile + ".zip");
TFile.cp_rp(src, dst, TArchiveDetector.NULL);
TFile.umount(dst);发布于 2011-09-30 14:13:18
找到了Apache的另一个库,Commons Compression。使用它而不是TrueZip。似乎也支持大于4 4gb的文件。
https://stackoverflow.com/questions/7597836
复制相似问题