MCPcopy Create free account
hub / github.com/annmuor/jnode / zipFile

Method zipFile

jnode-core/src/jnode/core/FileUtils.java:97–112  ·  view source on GitHub ↗

zip file @param inPath source @param outPath destination @param nameInsideZip zip entry name @throws IOException

(String inPath, String outPath, String nameInsideZip)

Source from the content-addressed store, hash-verified

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

Callers 1

moveToZipMethod · 0.95

Calls 2

readMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected