gpt4 book ai didi

java - 使用 ColdFusion 解压缩 64 位 zip 文件

转载 作者:行者123 更新时间:2023-11-30 09:25:54 25 4
gpt4 key购买 nike

我使用 java.util.zip.ZipFile 通过 ColdFusion 解压大文件。但是,我现在收到此错误:“无效的 CEN header (错误的签名)”。

我发现一篇文章表明这​​与 64 位 zip 格式有关,我可以使用 java.util.zip.ZipInputStream 来处理它。但是,我无法克服这个错误:“您试图取消引用类 [B 类型的标量变量作为具有成员的结构。”这是由这一行引起的:

bos = createObject("java","java.io.BufferedOutputStream").init(fos,buffer.length);

非常感谢任何帮助!

这是我的代码

    fis = createObject("java","java.io.FileInputStream").init(zipFilePath);
bis = createObject("java", "java.io.BufferedInputStream").init(fis);
zis = createObject("java", "java.util.zip.ZipInputStream").init(bis);

cnt=0;
while(1==1){
cnt++;
entry = zis.getNextEntry();
if (isNull(entry))
{
writeOutput("done"&now());
break;
}

nm = entry.getName();

lenPth = len(nm) - len(getFileFromPath(nm));

if (lenPth) {
pth = outputPath & left(nm, lenPth);
} else {
pth = outputPath;
}

if (NOT directoryExists(pth)) {
fil = createObject("java", "java.io.File");
fil.init(pth);
fil.mkdirs();
}

byteClass = createObject("java", "java.lang.Byte").TYPE;
buffer = createObject("java","java.lang.reflect.Array").newInstance(byteClass, 2048);

fos = createObject("java","java.io.FileOutputStream").init(outputPath & nm);
bos = createObject("java","java.io.BufferedOutputStream").init(fos,buffer.length);

while(1==1) {
size = zis.read(buffer, 0, buffer.length);
if(size == -1)
break;
bos.write(buffer, 0, size);
}
bos.flush();
bos.close();



}

zis.close();
fis.close();

来源:

最佳答案

传入 ArrayLen( Buffer ) 而不是 buffer.length 将解决错误。

bos = createObject("java","java.io.BufferedOutputStream").init(fos,arrayLen(buffer));

您还可以使用 java.lang.reflect.ArraygetLength( array ) 方法,但与使用 相比,创建另一个实例似乎有些矫枉过正arrayLen()

关于java - 使用 ColdFusion 解压缩 64 位 zip 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15094703/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com