captaincanuck_2004
New Member
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. This is what I am doing\[code\]byte b[] = new byte[10240];ZipOutputStream zout = new ZipOutputStream(getOutputStream("ExampleForms.zip", attach));for(int i = 0; i < pdfs.length; i++){ File f = File.createTempFile(pdfs.NAME, ".pdf"); FileOutputStream fo = new FileOutputStream(f); pdfs.render(fo); fo.close(); InputStream in = new FileInputStream(f); ZipEntry e = new ZipEntry(pdfs.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\]