public class CompressUtil extends Object
| 构造器和说明 |
|---|
CompressUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
compressNoParentZip(File sourceFile,
ZipOutputStream zos,
String name) |
static String |
compressToZip(File sourceFile,
String targetPath)
压缩为zip格式,支持文件、文件夹的压缩
|
static String |
compressToZip(String sourcePath,
String targetPath)
压缩为zip格式,支持文件、文件夹的压缩
|
static String |
unpackExportZipEntry(ZipFile zipFile,
ZipEntry entry,
String targetPath) |
static void |
unpackZip(File sourceFile,
String targetPath) |
static void |
unpackZip(String sourcePath,
String targetPath)
解压zip格式的压缩包
|
static List<String> |
unZip(InputStream input,
String fileId,
String scanDir)
解压 zip 文件
|
static File |
validateSourcePath(String sourcePath)
源文件路径判断
|
static File |
validateTargetPath(String targetPath)
解压路径存在判断
|
public static String compressToZip(String sourcePath, String targetPath)
sourcePath - 被压缩文件地址targetPath - 压缩文件保存地址public static String compressToZip(File sourceFile, String targetPath)
sourceFile - 被压缩文件targetPath - 压缩文件保存地址public static String unpackExportZipEntry(ZipFile zipFile, ZipEntry entry, String targetPath) throws IOException
IOExceptionpublic static void unpackZip(String sourcePath, String targetPath)
sourcePath - 待解压文件路径targetPath - 解压路径public static File validateSourcePath(String sourcePath)
sourcePath - 待解压文件路径public static File validateTargetPath(String targetPath)
targetPath - public static void compressNoParentZip(File sourceFile, ZipOutputStream zos, String name) throws IOException
IOExceptionpublic static List<String> unZip(InputStream input, String fileId, String scanDir) throws IOException
ExceptionIOExceptionCopyright © 2023. All rights reserved.