我编写了一个JAVA源代码来压缩Oracle DB 11g中的文件。该程序正在按预期工作,即在/home/oracle/目录中创建zip文件。但是,当我通过FTP将文件下载到硬盘或使用SMTP服务器发送电子邮件时,7Zip拒绝读取存档的内容,并抛出错误:-
“不支持的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);
}
}
}发布于 2015-08-10 09:12:14
正如@peter-lawrey所写的,如果您将zip存档从/home/oracle/.解压缩,那么首先检查它是否有效。如果是,也许您必须检查服务器和PC之间的传输是否破坏了文件(例如,如果您使用ftp协议传输zip文件,请注意传输时使用的数据类型)。
https://stackoverflow.com/questions/31911511
复制相似问题