public static byte[] fileToZip(){ ZipOutputStream append = null; ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { append = new ZipOutputStream(bos); ZipEntry e = new ZipEntry("request.xml"); append.putNextEntry(e); append.write(filteToByte("G:\tmp\request.xml")); append.closeEntry(); e = new ZipEntry("CONTENT\content.xml"); append.putNextEntry(e); append.write(filteToByte("G:\tmp\content.xml")); append.closeEntry(); } catch (FileNotFoundException ex) { Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex); } finally{ if(null != append){ try { append.close(); } catch (IOException ex) { Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex); } } } return bos.toByteArray(); }