use of org.apache.commons.compress.compressors.deflate.DeflateCompressorOutputStream in project beam by apache.
the class TextIOTest method writeToFile.
private static File writeToFile(String[] lines, String filename, CompressionType compression) throws IOException {
File file = tempFolder.resolve(filename).toFile();
OutputStream output = new FileOutputStream(file);
switch(compression) {
case UNCOMPRESSED:
break;
case GZIP:
output = new GZIPOutputStream(output);
break;
case BZIP2:
output = new BZip2CompressorOutputStream(output);
break;
case ZIP:
ZipOutputStream zipOutput = new ZipOutputStream(output);
zipOutput.putNextEntry(new ZipEntry("entry"));
output = zipOutput;
break;
case DEFLATE:
output = new DeflateCompressorOutputStream(output);
break;
default:
throw new UnsupportedOperationException(compression.toString());
}
writeToStreamAndClose(lines, output);
return file;
}
Aggregations