title: How to convert a InputStream to ZIP format?
body: <p>I am having a InputStream Object which is actually a zip file. I want to change it back to zip file and save it. I am using DWR's FileTransfer class object to receive the uploaded data from client. </p>
  
  <p><a href="http://www.jarvana.com/jarvana/view/org/directwebremoting/dwr/3.0.M1/dwr-3.0.M1-javadoc.jar!/org/directwebremoting/io/FileTransfer.html" rel="nofollow">FileTransfer</a> have 3 methods, <a href="http://www.jarvana.com/jarvana/view/org/directwebremoting/dwr/3.0.M1/dwr-3.0.M1-javadoc.jar!/org/directwebremoting/io/FileTransfer.html#getInputStream%28%29" rel="nofollow">getInputStream()</a> is one of them. It returns InputStream from FileTransfer object. </p>
  
  <p>In my case, fileTransfer object holds zip file and as well as InputStream object too.
  I have done, lot of searches in google. But i am not able to find one example, that illustrates InputStream to zip conversion.</p>
  
  <p><strong>Update</strong></p>
  
  <pre><code>String zipName = file.getName();
  String zipType = file.getMimeType();
  InputStream zipStream = file.getInputStream();
  ZipInputStream zis = new ZipInputStream(zipStream);
  System.out.println("File Name: "+zipName+"\n"+"File Type: "+zipType);
  int c;
  File f2 = new File(DATA_STORE_LOC+dat+".zip");
  path.setPath2(DATA_STORE_LOC+dat+".zip");
  FileOutputStream fos = new FileOutputStream(f2);
  ZipOutputStream zos = new ZipOutputStream(fos);
  c = zis.read();
  System.out.println(c);
  while ((c = zis.read(BUFFER)) != -1) {
  zos.write(BUFFER, 0, c);
  }
  zos.close();
  zis.close();
  </code></pre>
  
  <p>I tried this code, by thought of a typical file copy program. I know it is false, just tried. It gives me <code>java.util.zip.ZipException: ZIP file must have at least one entry</code>.</p>
  
  <p>Any suggestion would be really appreciative!!!!!</p>