title: Attaching an XML file in a zip file with other PDF files
body: <p>I have an outputstream of xml document. I am attaching all PDF files in one zip file. Once I am done attaching all PDF files , I want to attach xml document. But all I get is the empty xml file. </p>
  
  <p>This is what I am doing</p>
  
  <pre><code>byte b[] = new byte[10240];
  ZipOutputStream zout = new ZipOutputStream(getOutputStream("ExampleForms.zip", attach));
  for(int i = 0; i &lt; pdfs.length; i++){
      File f = File.createTempFile(pdfs[i].NAME, ".pdf");
      FileOutputStream fo = new FileOutputStream(f);
      pdfs[i].render(fo);
      fo.close();
      InputStream in = new FileInputStream(f);
      ZipEntry e = new ZipEntry(pdfs[i].NAME + ".pdf");
      zout.putNextEntry(e);
      int len=0;
      while((len=in.read(b)) != -1) {
            zout.write(b,0,len);
      }
      in.close();
      zout.closeEntry();
      f.delete();
  }       
  /* out is my outputstream in which i have written xml document */
  File f = File.createTempFile("SampleXmlFile.xml");
  FileOutputStream fo = new FileOutputStream(f);
  fo.write(out.toString().getBytes());
  fo.close();
  InputStream is = new FileInputStream(f);
  ZipEntry e = new ZipEntry("MyXmlFile",".xml");
  zout.putNextEntry(e);
  int lent = 0;
  while((lent = is.read(bt)) != -1){
     zout.write(bt,0,lent);
  }
  is.close();
  zout.closeEntry();
  zout.close();
  </code></pre>