Package javax.activation

Examples of javax.activation.DataSource


        Iterator attachmentIterator = attachments.iterator();
        while (attachmentIterator.hasNext()) {
          messageBodyPart = new MimeBodyPart();
          CvFileVO thisAttachment = (CvFileVO) attachmentIterator.next();
          String path = thisAttachment.getPhysicalFolderVO().getFullPath(null, true) + thisAttachment.getName();
          DataSource source = new FileDataSource(path);
          messageBodyPart.setDataHandler(new DataHandler(source));
          messageBodyPart.setFileName(thisAttachment.getTitle());
          multipart.addBodyPart(messageBodyPart);
        }
      }
View Full Code Here


        Iterator attachmentIterator = attachments.iterator();
        while (attachmentIterator.hasNext()) {
          messageBodyPart = new MimeBodyPart();
          CvFileVO thisAttachment = (CvFileVO) attachmentIterator.next();
          String path = thisAttachment.getPhysicalFolderVO().getFullPath(null, true) + thisAttachment.getName();
          DataSource source = new FileDataSource(path);
          messageBodyPart.setDataHandler(new DataHandler(source));
          messageBodyPart.setFileName(thisAttachment.getTitle());
          multipart.addBodyPart(messageBodyPart);
        }
      }
View Full Code Here

      Template temp = new Template(name, new InputStreamReader(src), cfg);
      final ByteArrayOutputStream bout = new ByteArrayOutputStream();
      Writer out = new OutputStreamWriter(bout);
      temp.process(renderContext, out);
      out.flush();
      merged = new DataHandler(new DataSource() {
        public InputStream getInputStream() throws IOException {
          return new ByteArrayInputStream(bout.toByteArray());
        }
        public OutputStream getOutputStream() throws IOException {
          return bout;
View Full Code Here

            //����htmlҳ���ϵ�ͼƬ�������£�
            private void processHtmlImage(String mailContent) throws MessagingException {
                for (int i = 0; i < arrayList1.size(); i++) {
                    messageBodyPart = new MimeBodyPart();
                    DataSource source = new FileDataSource((String) arrayList1.get(i));
                    messageBodyPart.setDataHandler(new DataHandler(source));
                    String contentId = "<" + (String) arrayList2.get(i) + ">";
                    messageBodyPart.setHeader("Content-ID", contentId);
                    messageBodyPart.setFileName((String) arrayList1.get(i));
                    multipart.addBodyPart(messageBodyPart);
View Full Code Here

     * @param attachmentName
     * @throws MessagingException
     */
    public void setAttachments(String attachmentName) throws MessagingException {
        messageBodyPart = new MimeBodyPart();
        DataSource source = new FileDataSource(attachmentName);
        messageBodyPart.setDataHandler(new DataHandler(source));
        int index = attachmentName.lastIndexOf(File.separator);
        String attachmentRealName = attachmentName.substring(index + 1);
        messageBodyPart.setFileName(attachmentRealName);
        multipart.addBodyPart(messageBodyPart);
View Full Code Here

          CvFileFacade cvfile  = new CvFileFacade();
          CvFileVO cvfilevo    = cvfile.getEmailAttachment(userId, Integer.parseInt(fileid), this.dataSource);

          String path          = cvfilevo.getPhysicalFolderVO().getFullPath(null, true) + cvfilevo.getName();

          DataSource source    = new FileDataSource(path);
          messageBodyPart.setDataHandler(new DataHandler(source));
          messageBodyPart.setFileName(name);
          multipart.addBodyPart(messageBodyPart);

        } //end of while loop(itt.hasNext())
View Full Code Here

        throws Exception
    {
        client.setProperty(SoapConstants.MTOM_ENABLED, "true");
        client.setProperty(HttpTransport.CHUNKING_ENABLED, "true");
       
        DataSource source = picClient.GetPicture();
        assertNotNull(source);
       
        DataSource pbsource = picClient.GetPictureBean().getData();
        assertNotNull(pbsource);
       
        InputStream is = pbsource.getInputStream();
        assertNotNull(is);
       
        FileDataSource fileSource = new FileDataSource(getTestFile("src/test-resources/xfire.jpg"));
        DataSource source2 = picClient.EchoPicture(fileSource);
        assertNotNull(source2);
       
        DataHandler handler = new DataHandler(source2);
        DataHandler handler2 = picClient.EchoPicture2(handler);
        assertNotNull(handler2);
View Full Code Here

        client.setProperty(HttpTransport.CHUNKING_ENABLED, "true");
        // Byte array
        String result = service.stringFromBytes("tsztelak@gmail.com".getBytes());
        System.out.print("Result : "+ result+"\n");
        // Data Source
        DataSource source = new ByteArrayDataSource("tsztelak@gmail.com".getBytes(), "text/plain; charset=UTF-8");
        result = service.stringFromDataSource(source);
        System.out.print("Result : "+ result+"\n");
        // Data Handler
        result = service.stringFromDataHandler(new DataHandler(source));
        System.out.print("Result : "+ result+"\n");
View Full Code Here


    public void testText()
        throws Exception
    {
        DataSource ds = new FileDataSource(
            getTestFile("src/test/org/codehaus/xfire/attachments/test.txt"));

        DataHandler handler = new DataHandler(ds);

        Object content = handler.getContent();
View Full Code Here

    }
   
    public void testImages()
        throws Exception
    {
        DataSource ds = new FileDataSource(
            getTestFile("src/test/org/codehaus/xfire/attachments/xfire_logo.jpg"));
   
        DefaultDataContentHandlerFactory factory = new DefaultDataContentHandlerFactory();

        Object content = factory.createDataContentHandler("image/jpeg").getContent(ds);
View Full Code Here

TOP

Related Classes of javax.activation.DataSource

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.