zip file @param inPath source @param outPath destination @param nameInsideZip zip entry name @throws IOException
(String inPath, String outPath, String nameInsideZip)
| 95 | * @throws IOException |
| 96 | */ |
| 97 | public static void zipFile(String inPath, String outPath, String nameInsideZip) throws IOException { |
| 98 | try(FileInputStream in = new FileInputStream(inPath)){ |
| 99 | try(ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outPath))){ |
| 100 | out.putNextEntry(new ZipEntry(nameInsideZip)); |
| 101 | |
| 102 | byte[] buffer = new byte[BLOCK_SIZE]; |
| 103 | int len; |
| 104 | |
| 105 | while ((len = in.read(buffer)) > 0) { |
| 106 | out.write(buffer, 0, len); |
| 107 | } |
| 108 | |
| 109 | out.closeEntry(); |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Get path part form full path |