use of org.apache.tools.zip.ZipOutputStream in project hive by apache.
the class CompressionUtils method zip.
public static void zip(String parentDir, String[] inputFiles, String outputFile) throws IOException {
ZipOutputStream output = null;
try {
output = new ZipOutputStream(new FileOutputStream(new File(parentDir, outputFile)));
for (int i = 0; i < inputFiles.length; i++) {
File f = new File(parentDir, inputFiles[i]);
FileInputStream input = new FileInputStream(f);
output.putNextEntry(new ZipEntry(inputFiles[i]));
try {
IOUtils.copy(input, output);
} finally {
input.close();
}
}
} finally {
org.apache.hadoop.io.IOUtils.closeStream(output);
}
}
use of org.apache.tools.zip.ZipOutputStream in project gradle by gradle.
the class DefaultZipCompressor method createArchiveOutputStream.
public ZipOutputStream createArchiveOutputStream(File destination) throws IOException {
ZipOutputStream outStream = new ZipOutputStream(destination);
try {
outStream.setUseZip64(zip64Mode);
outStream.setMethod(entryCompressionMethod);
return outStream;
} catch (Exception e) {
IOUtils.closeQuietly(outStream);
String message = String.format("Unable to create ZIP output stream for file %s.", destination);
throw new UncheckedIOException(message, e);
}
}
Aggregations