文件打包时,为什么不能导入这些包?
import org.apache.commons.compress.archivers.ArchiveEntry;import org.apache.commons.compress.archivers.zip.Zip64Mode;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; --------------------编程问答-------------------- 要确认相关的jar文件是否导入了 --------------------编程问答-------------------- 在配置文件里手动加入 --------------------编程问答-------------------- 1、包是什么格式的?
2、是否添加到编译区了? --------------------编程问答-------------------- 导入的jar包错了。大神们有这个jar包没 ? --------------------编程问答--------------------
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipOutputStream;
/**
* 压缩文件
* @param filePaths 存放文件物理路径的集合
* @param fileNames 文件的名称(和文件路径对应,可以是中文)
* @param outPath 压缩文件的输出路径(物理路径)
*/
public void reduceFile(List<String> filePaths, List<String> fileNames, String outPath) {
if (null != filePaths && filePaths.size() > 0 && null != fileNames && fileNames.size()== filePaths.size()) {
try {
OutputStream fileOutput = new FileOutputStream(outPath);
ZipOutputStream zipOutput = new ZipOutputStream(fileOutput);
for (int i = 0; i < filePaths.size(); i++) {
File file = new File(filePaths.get(i));
if (file.exists() && !file.isDirectory()) {
InputStream input = new FileInputStream(file);
ZipEntry entry = new ZipEntry(fileNames.get(i));
zipOutput.putNextEntry(entry);
int length = 0;
while ((length = input.read()) != -1) {
zipOutput.write(length);
}
input.close();
}
}
zipOutput.setEncoding("GBK");
zipOutput.flush();
zipOutput.closeEntry();
zipOutput.close();
fileOutput.flush();
fileOutput.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
补充:Java , Java EE