package com.sourcefellows.patterns.factory;

import org.apache.commons.compress.compressors.CompressorException;
import org.apache.commons.compress.compressors.CompressorOutputStream;
import org.apache.commons.compress.compressors.CompressorStreamFactory;

import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;

public class Main {

    public static void main(String[] args) throws IOException, CompressorException {

    var myOutputStream = Files.newOutputStream(Paths.get("my.gz"));
    CompressorOutputStream gzippedOut = new CompressorStreamFactory()
            .createCompressorOutputStream(CompressorStreamFactory.GZIP, myOutputStream);

    gzippedOut.write("Hello World".getBytes(Charset.defaultCharset()));

    }
}
