title: How to zip a single string with ZipOutputStream and save as a readable string
body: <p>I tried to compress a string with DeflaterOutputStream and converted the output with base64 to save the result in another string</p>
  
  <pre><code>public static String compress(String str) throws IOException {
      byte[] data = str.getBytes("UTF-8");
      ByteArrayOutputStream stream = new ByteArrayOutputStream();
      java.util.zip.Deflater compresser = new java.util.zip.Deflater(java.util.zip.Deflater.BEST_COMPRESSION, true);
      DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(stream, cozmpresser);
      deflaterOutputStream.write(data);
      deflaterOutputStream.close();
      byte[] output = stream.toByteArray();
      return Base64Coder.encodeLines(output);
  }
  </code></pre>
  
  <p>Now i wish to try ZipOutputStream. i tried</p>
  
  <pre><code>public static String compress(String str) throws IOException {
      byte[] data = str.getBytes("UTF-8");
      ByteArrayOutputStream stream = new ByteArrayOutputStream();
      ZipOutputStream deflaterOutputStream = new ZipOutputStream(stream);
      deflaterOutputStream.setMethod(ZipOutputStream.DEFLATED);
      deflaterOutputStream.setLevel(8);
      deflaterOutputStream.write(data);
      deflaterOutputStream.close();
      byte[] output = stream.toByteArray();
      return Base64Coder.encodeLines(output);
  }
  </code></pre>
  
  <p>But dont work. ZipOutputStream seems orientated to a structure of folders and files
  how can I do?</p>