Package javax.activation

Examples of javax.activation.DataHandler.writeTo()


    throws IOException
  {
    DataHandler handler = (DataHandler) obj;
    handler.setCommandMap(com.caucho.xml.saaj.SAAJCommandMap.COMMAND_MAP);

    handler.writeTo(out);
  }

  public Object readFromAttachment(Attachment attachment)
    throws IOException
  {
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

    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

                DataSource dataSource = dh.getDataSource();
                //Ask the data source to stream, if it has not alredy cached the request
                if (!preserve && dataSource instanceof StreamingOnRequestDataSource) {
                    ((StreamingOnRequestDataSource) dataSource).setLastUse(true);
                }
                dh.writeTo(out);
            }
        } catch (OMException e) {
            log.error(e);
            throw AxisFault.makeFault(e);
        } catch (IOException e) {
View Full Code Here

            if (dbReportingServiceClient != null) {
                dataHandler = dbReportingServiceClient.getReport(reportBean,reportParamMapsList.toArray(new ReportParamMap[reportParamMapsList.size()]));
            }
            ServletOutputStream outputStream = response.getOutputStream();
            if (dataHandler != null) {
                dataHandler.writeTo(outputStream);
            }
        } catch (Exception e) {
            log.error("Failed to handle report request ",e);
            throw e;
        }
View Full Code Here

        ByteArrayOutputStream output = null;
        //             OutputStream output = new FileOutputStream(tempFile);
        output = new ByteArrayOutputStream();
        try {
            dataHandler.writeTo(output);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            throw e;
        }
View Full Code Here

        }
        DataHandler dh = new DataHandler(src.toURL());
        FileOutputStream out = null;
        try {
            out = new FileOutputStream(dst);
            dh.writeTo(out);
            out.flush();
        } finally {
            if (out != null) {
                out.close();
            }
View Full Code Here

        assertNotNull(((Map)result).get("foo"));
        assertTrue(((Map)result).get("foo") instanceof DataHandler);
        DataHandler dh = (DataHandler)((Map)result).get("foo");
        ByteArrayOutputStream baos = new ByteArrayOutputStream(4);
        dh.writeTo(baos);
        assertEquals("foovalue", baos.toString());

        assertNotNull(((Map)result).get("baz"));
        assertTrue(((Map)result).get("baz") instanceof DataHandler);
        dh = (DataHandler)((Map)result).get("baz");
View Full Code Here

        assertNotNull(((Map)result).get("baz"));
        assertTrue(((Map)result).get("baz") instanceof DataHandler);
        dh = (DataHandler)((Map)result).get("baz");
        baos = new ByteArrayOutputStream(4);
        dh.writeTo(baos);
        assertEquals("bazvalue", baos.toString());

        result = eval.evaluate("fool?", message);
        assertNotNull(result);
        assertTrue(result instanceof Map);
View Full Code Here

        assertEquals(2, ((List)result).size());

        assertTrue(((List)result).get(0) instanceof DataHandler);
        DataHandler dh = (DataHandler)((List)result).get(0);
        ByteArrayOutputStream baos = new ByteArrayOutputStream(4);
        dh.writeTo(baos);
        assertEquals("foovalue", baos.toString());

        assertTrue(((List)result).get(1) instanceof DataHandler);
        dh = (DataHandler)((List)result).get(1);
        baos = new ByteArrayOutputStream(4);
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.