public String saveEmbededResponse( String downloadDirectory, String localFileName, com.actuate.schemas.DownloadFileResponse downloadFileResponse, boolean decomposed) throws IOException, RemoteException { String downloadName = null; BufferedOutputStream outStream = null; String localFilePath = downloadDirectory + "/" + localFileName; try { if (!decomposed) { outStream = new BufferedOutputStream(new FileOutputStream(localFilePath)); } com.actuate.schemas.Attachment attachment = downloadFileResponse.getContent(); if (attachment != null) { byte[] b = attachment.getContentData(); System.out.println("Attachment retrived as " + attachment.getContentId()); if (b != null && outStream != null) { outStream.write(b); } } com.actuate.schemas.ArrayOfAttachment arrayOfAttachment = downloadFileResponse.getContainedFiles(); if (arrayOfAttachment != null) { com.actuate.schemas.Attachment[] attachments = arrayOfAttachment.getAttachment(); for (int i = 0; i < attachments.length; i++) { if (attachments[i] != null) { byte[] b = attachments[i].getContentData(); System.out.println("Attachment retrived as " + attachments[i].getContentId()); if (b != null) { if (outStream != null) { outStream.write(b); } else { String decomposedDocAttachment = downloadDirectory + "/" + attachments[i].getContentId(); BufferedOutputStream tempOutStream = new BufferedOutputStream(new FileOutputStream(decomposedDocAttachment)); tempOutStream.write(b); tempOutStream.close(); } } } } } } catch (RemoteException e) { throw e; } finally { if (outStream != null) { downloadName = localFilePath; outStream.close(); } } return downloadName; }