Package javax.activation

Examples of javax.activation.DataHandler.writeTo()


        assertEquals("moo", baos.toString());

        assertTrue(((List)result).get(1) instanceof DataHandler);
        dh = (DataHandler)((List)result).get(1);
        baos = new ByteArrayOutputStream(4);
        dh.writeTo(baos);
        assertEquals("maz", baos.toString());       
       
        result = muleContext.getExpressionManager().evaluate("#[mule:message.attachments-list(fool?)]", createMessageWithAttachments());
        assertEquals(0, ((List)result).size());
View Full Code Here


    protected void checkMessageData(XMLMessage expected, XMLMessage actual) throws Exception {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        Attachments attachments = actual.getAttachments();
        DataHandler dataHandler = attachments.getDataHandler(contentID);
        assertNotNull(dataHandler);
        dataHandler.writeTo(baos);
        assertTrue(Arrays.equals(attachmentContent, baos.toByteArray()));
    }
}
View Full Code Here

                  // 'application/octet-stream' will return a byte[] instead fo the stream
                  if (obj instanceof InputStream)
                  {
                     ByteArrayOutputStream bout = new ByteArrayOutputStream();
                     dh.writeTo(bout);
                     obj = bout.toByteArray();
                  }
               }
               catch (IOException e)
               {
View Full Code Here

         DataHandler dh = part.getDataHandler();
         contentType = dh.getContentType();

         // TODO: can't we create base64 directly from stream?
         ByteArrayOutputStream bout = new ByteArrayOutputStream();
         dh.writeTo(bout);
         data = bout.toByteArray();

      }
      catch (Exception e)
      {
View Full Code Here

            }
            serviceArchive = new File(tempDirName + File.separator + serviceGroupName);
            FileOutputStream out = null;
            try {
                out = new FileOutputStream(serviceArchive);
                dh.writeTo(out);
                out.close();
            } finally {
                if (out != null) {
                    out.close();
                }
View Full Code Here

        Attachments attachment  = response.getAttachmentMap();
        dataHandler = attachment.getDataHandler(imageContentId);
        File tempFile = File.createTempFile("swa-", ".gif");
        FileOutputStream fos = new FileOutputStream(tempFile);
        dataHandler.writeTo(fos);
    fos.flush();
    fos.close();

        System.out.println("Saved response to file : " + tempFile.getAbsolutePath());
    }
View Full Code Here

        MessageContext msgCtx   = MessageContext.getCurrentMessageContext();
        Attachments attachment  = msgCtx.getAttachmentMap();
        DataHandler dataHandler = attachment.getDataHandler(imageContentId);
        File tempFile = File.createTempFile("swa-", ".gif");
        FileOutputStream fos = new FileOutputStream(tempFile);
        dataHandler.writeTo(fos);
    fos.flush();
    fos.close();
        System.out.println("Wrote SwA attachment to temp file : " + tempFile.getAbsolutePath());

        MessageContext outMsgCtx = msgCtx.getOperationContext().
View Full Code Here

        Attachments attachment = msgCtx.getAttachmentMap();
        DataHandler dataHandler = attachment.getDataHandler(attchmentID);
        File file = new File(
        name);
    FileOutputStream fileOutputStream = new FileOutputStream(file);
    dataHandler.writeTo(fileOutputStream);
    fileOutputStream.flush();
    fileOutputStream.close();
   
    return "File saved succesfully.";
  }
View Full Code Here

          } else if (type.equals(STRING)) {
            this.put((Object)name, text.getText());
          } else if (type.equals(BYTEARRAY)) {
            DataHandler dh = (DataHandler)text.getDataHandler();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            dh.writeTo(baos);
            this.put((Object)name, baos.toByteArray());
          }
          } catch (Exception e) {
            e.printStackTrace();
            // ignore errors
View Full Code Here

        Attachments attachment = response.getAttachmentMap();
        dataHandler = attachment.getDataHandler(imageContentId);
        File tempFile = File.createTempFile("swa-", ".gif");
        FileOutputStream fos = new FileOutputStream(tempFile);
        dataHandler.writeTo(fos);
        fos.flush();
        fos.close();

        System.out.println("Saved response to file : " + tempFile.getAbsolutePath());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.