|
@@ -130,10 +130,18 @@ public class Zip4jUtil {
|
|
*/
|
|
*/
|
|
private static void commonUnZipFile(String scrPath, String destPath, String password) {
|
|
private static void commonUnZipFile(String scrPath, String destPath, String password) {
|
|
try {
|
|
try {
|
|
|
|
+ File file = new File(scrPath);
|
|
|
|
+ if (!file.exists()) {
|
|
|
|
+ file.getParentFile().mkdirs();
|
|
|
|
+ }
|
|
ZipFile zipFile = new ZipFile(scrPath);
|
|
ZipFile zipFile = new ZipFile(scrPath);
|
|
if (Objects.nonNull(password) && zipFile.isEncrypted()) {
|
|
if (Objects.nonNull(password) && zipFile.isEncrypted()) {
|
|
zipFile.setPassword(password);
|
|
zipFile.setPassword(password);
|
|
}
|
|
}
|
|
|
|
+ File currentFile = new File(destPath);
|
|
|
|
+ if (!currentFile.exists()) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("待解压的路径不存在");
|
|
|
|
+ }
|
|
zipFile.extractAll(destPath);
|
|
zipFile.extractAll(destPath);
|
|
} catch (ZipException e) {
|
|
} catch (ZipException e) {
|
|
log.error(SystemConstant.LOG_ERROR, e);
|
|
log.error(SystemConstant.LOG_ERROR, e);
|
|
@@ -151,6 +159,10 @@ public class Zip4jUtil {
|
|
*/
|
|
*/
|
|
private static void commonZipFile(String scrPath, String destPath, List<File> files, String password) {
|
|
private static void commonZipFile(String scrPath, String destPath, List<File> files, String password) {
|
|
try {
|
|
try {
|
|
|
|
+ File file = new File(scrPath);
|
|
|
|
+ if (!file.exists()) {
|
|
|
|
+ file.getParentFile().mkdirs();
|
|
|
|
+ }
|
|
// 生成的压缩文件
|
|
// 生成的压缩文件
|
|
ZipFile zipFile = new ZipFile(scrPath);
|
|
ZipFile zipFile = new ZipFile(scrPath);
|
|
ZipParameters parameters = new ZipParameters();
|
|
ZipParameters parameters = new ZipParameters();
|
|
@@ -168,7 +180,7 @@ public class Zip4jUtil {
|
|
File[] fs = null;
|
|
File[] fs = null;
|
|
if (!CollectionUtil.isEmpty(files)) {
|
|
if (!CollectionUtil.isEmpty(files)) {
|
|
// 要打包的文件夹
|
|
// 要打包的文件夹
|
|
- fs = files.toArray(new File[0]);
|
|
|
|
|
|
+ fs = files.toArray(new File[files.size()]);
|
|
} else if (Objects.nonNull(destPath)) {
|
|
} else if (Objects.nonNull(destPath)) {
|
|
File currentFile = new File(destPath);
|
|
File currentFile = new File(destPath);
|
|
if (!currentFile.exists()) {
|
|
if (!currentFile.exists()) {
|