code: public <T extends OutputStream> T write(T os) throws IOException {
          close();
  
          if (!(this.os instanceof ByteArrayOutputStream))
              throw new IllegalStateException("Cannot write to another target if setOutputStream has been called");
          final byte[] content = ((ByteArrayOutputStream) this.os).toByteArray();
  
          if (packer != null)
              packer.pack(new JarInputStream(new ByteArrayInputStream(content)), os);
          else
              os.write(content);
  
          os.close();
          return os;
      }
docs: Writes this JAR to an output stream, and closes the stream.