public SpritzOutputStream(final Optional<String> fname, final String key, final OutputStream out) throws IOException { internalName = fname; encrypter = new SpritzEncrypter(key, out); byte[] nameBytes = fname .map(n -> new File(n).getName()) .orElse("") .getBytes(java.nio.charset.StandardCharsets.UTF_8); encrypter.write(nameBytes.length); encrypter.write(nameBytes); final Deflater zlibAlgo = new Deflater(Deflater.BEST_COMPRESSION); deflater = new DeflaterOutputStream(encrypter, zlibAlgo); }
@Override public void close() throws Exception { deflater.finish(); deflater.close(); encrypter.close(); }