gpt4 book ai didi

java - 7Zip 无法解压缩由 Oracle 11g DB 中的 JAVA 源创建的文件

转载 作者:搜寻专家 更新时间:2023-11-01 03:49:39 26 4
gpt4 key购买 nike

我已经编写了一个 JAVA 源代码来压缩 Oracle DB 11g 中的文件。该程序按预期工作,即它正在 /home/oracle/ 目录中创建 zip 文件。但是当我通过 FTP 下载文件到我的硬盘或使用 SMTP 服务器通过电子邮件发送它们时,7Zip 拒绝读取存档的内容并抛出错误:-

"Unsupported compression method for DAR.xls"

我是不是做错了什么?请帮忙。

附上JAVA源代码:

CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "UTLZip" AS
import java.util.zip.*;
import java.io.*;
public class UTLZip
{
public static void compressFile(String infilename, String outfilename)
{
String zipFile = "/home/oracle/DAR.zip";

String[] srcFiles = {"/home/oracle/DAR.xls"};

try {

// create byte buffer
byte[] buffer = new byte[1024];

FileOutputStream fos = new FileOutputStream(zipFile);

ZipOutputStream zos = new ZipOutputStream(fos);

for (int i=0; i < srcFiles.length; i++) {

File srcFile = new File(srcFiles[i]);

FileInputStream fis = new FileInputStream(srcFile);


zos.putNextEntry(new ZipEntry(srcFile.getName()));

int length;

while ((length = fis.read(buffer)) > 0) {
zos.write(buffer, 0, length);
}

zos.closeEntry();

// close the InputStream
fis.close();

}

// close the ZipOutputStream
zos.close();

}
catch (IOException ioe) {
System.out.println("Error creating zip file: " + ioe);
}

}

}

最佳答案

正如@peter-lawrey 所写,如果您从 /home/oracle/ 解压缩 zip 存档,首先检查它是否有效。如果是,您可能需要检查服务器和 PC 之间的传输是否损坏了文件(例如,如果您使用 ftp 协议(protocol)传输 zip 文件,请注意数据-传输时使用的类型)

关于java - 7Zip 无法解压缩由 Oracle 11g DB 中的 JAVA 源创建的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31911511/

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