Package javax.activation

Examples of javax.activation.DataHandler


            mimeType = "application/octet-stream";
        }
       
        ByteDataSource source = new ByteDataSource(data, offset, length);
        source.setContentType(mimeType);
        DataHandler handler = new DataHandler(source);

        String id;
        try {
            id = AttachmentUtil.createContentID(elementNS);
        } catch (UnsupportedEncodingException e) {
View Full Code Here


    Document doc = parse(baseURI.resolve("entry_content_base64.xml"));
    Feed feed = (Feed)doc.getRoot();
    Entry entry = feed.getEntries().get(0);
    Content mediaContent = entry.getContentElement();
    assertEquals(mediaContent.getMimeType().toString(), "application/octet-stream");
    DataHandler dataHandler = mediaContent.getDataHandler();
    InputStream in = (ByteArrayInputStream) dataHandler.getContent();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    int n = -1;
    while ((n = in.read()) > -1) { baos.write(n); }
    assertEquals(baos.toString(), "Example <b>Atom</b>");
  }
View Full Code Here

    Document doc = parse(baseURI.resolve("entry_content_base64_2.xml"));
    Feed feed = (Feed)doc.getRoot();
    Entry entry = feed.getEntries().get(0);
    Content mediaContent = entry.getContentElement();
    assertEquals(mediaContent.getMimeType().toString(), "application/octet-stream");
    DataHandler dataHandler = mediaContent.getDataHandler();
    InputStream in = (ByteArrayInputStream) dataHandler.getContent();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    int n = -1;
    while ((n = in.read()) > -1) { baos.write(n); }
    assertEquals(baos.toString(), "<p>History of the &lt;blink&gt; tag</p>");
  }
View Full Code Here

        ((SOAPBinding)binding).setMTOMEnabled(true);

        Holder<String> name = new Holder<String>("Sam");
        URL fileURL = this.getClass().getResource("/org/apache/cxf/systest/jms/JMSClientServerTest.class");
        Holder<DataHandler> handler1 = new Holder<DataHandler>();
        handler1.value = new DataHandler(fileURL);
        int size = handler1.value.getInputStream().available();
        mtom.testDataHandler(name, handler1);
       
        byte bytes[] = IOUtils.readBytesFromStream(handler1.value.getInputStream());
        assertEquals("The response file is not same with the sent file.", size, bytes.length);
View Full Code Here

        return getContentStream();
    }

    public synchronized DataHandler getDataHandler() throws MessagingException {
        if (dh == null) {
            dh = new DataHandler(new MimePartDataSource(this));
        }
        return dh;
    }
View Full Code Here

    public void setDataHandler(DataHandler handler) throws MessagingException {
        dh = handler;
    }

    public void setContent(Object content, String type) throws MessagingException {
        setDataHandler(new DataHandler(content, type));
    }
View Full Code Here

    public void setText(String text, String charset) throws MessagingException {
        setContent(text, "text/plain; charset=" + charset);
    }

    public void setContent(Multipart part) throws MessagingException {
        setDataHandler(new DataHandler(part, part.getContentType()));
        part.setParent(this);
    }
View Full Code Here

        return getContentStream();
    }

    public synchronized DataHandler getDataHandler() throws MessagingException {
        if (dh == null) {
            dh = new DataHandler(new MimePartDataSource(this));
        }
        return dh;
    }
View Full Code Here

    public void setDataHandler(DataHandler handler) throws MessagingException {
        dh = handler;
    }

    public void setContent(Object content, String type) throws MessagingException {
        setDataHandler(new DataHandler(content, type));
    }
View Full Code Here

    public void setText(String text, String charset) throws MessagingException {
        setContent(text, "text/plain; charset=" + charset);
    }

    public void setContent(Multipart part) throws MessagingException {
        setDataHandler(new DataHandler(part, part.getContentType()));
        part.setParent(this);
    }
View Full Code Here

TOP

Related Classes of javax.activation.DataHandler

Copyright © 2018 www.massapicom. 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.