package de.ivu.elect.exchange.zip;

import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

public class ZipOutputStreamBuilder {

  public ZipOutputStream createZipOutputStream(OutputStream os) {
    // HINT (Cp437): Damit Umlaute wie "München" korrekt dargestellt werden,
    // cf. http://stackoverflow.com/questions/11276343/zipinputstreaminputstream-charset-decodes-zipentry-file-name-falsely
    return new ZipOutputStream(os, Charset.forName("Cp437"));
  }

  public void beginNewZipEntry(ZipOutputStream zos, String dateiName) throws IOException {
    zos.putNextEntry(new ZipEntry(dateiName));
  }

}
