文档压缩 @param file 需要压缩的文件或目录 @param dest 压缩后的文件名称 @throws IOException
(File file, String dest)
| 18 | * @throws IOException |
| 19 | */ |
| 20 | public static void deCompress(File file, String dest) throws IOException { |
| 21 | try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(dest))) { |
| 22 | String dir = ""; |
| 23 | if (file.isDirectory()) { |
| 24 | dir = file.getName(); |
| 25 | } |
| 26 | zipFile(file, zos, dir); |
| 27 | } catch (IOException e) { |
| 28 | throw e; |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | public static void zipFile(File inFile, ZipOutputStream zos, String dir) throws IOException { |
| 33 | if (inFile.isDirectory()) { |