Package javax.activation

Examples of javax.activation.DataHandler


  private static void copyHTTPToFile (String sSource, String sTarget)
    throws MalformedURLException,IOException {
    URL oUrl = new URL(sSource);
    FileOutputStream oTrgt = new FileOutputStream(sTarget.substring(7));
    DataHandler oHndlr = new DataHandler(oUrl);
    oHndlr.writeTo(oTrgt);
    oTrgt.close();
  } // copyHTTPToFile
View Full Code Here


      URL oUrl = new URL(sFilePath);

    if (user().equals("anonymous") || user().length()==0) {
        ByteArrayOutputStream oStrm = new ByteArrayOutputStream();
        DataHandler oHndlr = new DataHandler(oUrl);
        oHndlr.writeTo(oStrm);
        aRetVal = oStrm.toByteArray();
        oStrm.close();
      } else {
      if (null==oHttpCli) {
        oHttpCli = new DefaultHttpClient();
View Full Code Here

    if (sLower.startsWith("http://") || sLower.startsWith("https://")) {

      URL oUrl = new URL(sFilePath);
    if (user().equals("anonymous") || user().length()==0) {
        ByteArrayOutputStream oStrm = new ByteArrayOutputStream();
        DataHandler oHndlr = new DataHandler(oUrl);
        oHndlr.writeTo(oStrm);
        sRetVal = oStrm.toString(sEncoding);
        oStrm.close();
    } else {
      if (null==oHttpCli) {       
        oHttpCli = new DefaultHttpClient();
View Full Code Here

              MimeBodyPart attachment = new MimeBodyPart();
                attachment.setFileName(item.getFilename());
                String mimeType = MimeType.getContentTypeByExt(
                    FolderUtil.getFileExt(item.getFilename()));
                DataSource ds = new ByteArrayDataSource(item.getData(), mimeType);
                attachment.setDataHandler(new DataHandler(ds));
                mp.addBodyPart(attachment);
            }
            MimeMessage msg = new MimeMessage(session);
            msg.setFrom(new InternetAddress(fromAddress, fromText));
            msg.addRecipient(Message.RecipientType.TO,
View Full Code Here

       
       
        MimeBodyPart attachment = new MimeBodyPart();

        DataSource  data_source  = new File_data_source( att.getFile(), att.getContentType() );
        DataHandler data_handler = new DataHandler( data_source );

        attachment.setDataHandler( data_handler );
        attachment.setFileName   ( att.getFile().getName() );

        //Charset des Attachments setzen, wenn content_type text/ ist
View Full Code Here

      // msg.setRecipients(Message.RecipientType.CC
      // ,InternetAddress.parse(cc, false));

      // -- Set the subject and body text --
      msg.setSubject(subject);
      msg.setDataHandler(new DataHandler(new ByteArrayDataSource(body,
          "text/html; charset=\"utf-8\"")));

      // -- Set some other header information --
      msg.setHeader("X-Mailer", "XML-Mail");
      msg.setSentDate(new Date());
View Full Code Here

    mimeMessage.setFrom(new InternetAddress(from));
    mimeMessage.addRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients, false));
   
    // -- Create a new message --
    BodyPart msg = new MimeBodyPart();
    msg.setDataHandler(new DataHandler(new ByteArrayDataSource(htmlBody, "text/html; charset=\"utf-8\"")));
   
    Multipart multipart = new MimeMultipart();
   
    BodyPart iCalAttachment = new MimeBodyPart();
    iCalAttachment.setDataHandler(new DataHandler(new javax.mail.util.ByteArrayDataSource(new ByteArrayInputStream(iCalMimeBody), "text/calendar;method=REQUEST;charset=\"UTF-8\"")));

    multipart.addBodyPart(iCalAttachment);
    multipart.addBodyPart(msg);
   
    mimeMessage.setContent(multipart);
View Full Code Here

  public DataHandler getDataHandler(long uid, long newUidValidity, boolean saveToCache) throws MessagingException {
    if (newUidValidity != uidValidity) {
      throw new StaleCacheException(uidValidity, newUidValidity);
    }

    DataHandler h = getHandlerFromCache(uid);
    if (h != null) {
      return h;
    } else {
      if (getFolderInfo().shouldBeConnected()) {
        MimeMessage m = getFolderInfo().getRealMessageById(uid);
View Full Code Here

  public MimeMessage getMessageRepresentation(long uid, long newUidValidity, boolean saveToCache) throws MessagingException {
    if (newUidValidity != uidValidity) {
      throw new StaleCacheException(uidValidity, newUidValidity);
    }

    DataHandler h = getHandlerFromCache(uid);

    File f = new File(cacheDir, uid + DELIMETER + CONTENT_EXT);
    if (f.exists()) {
      try {
        FileInputStream fis = new FileInputStream(f);
View Full Code Here

    if (f.exists()) {
      try {
        FileInputStream fis = new FileInputStream(f);
        MimeMessage mm = new MimeMessage(net.suberic.pooka.Pooka.getDefaultSession(), fis);
        javax.activation.DataSource source = new WrappedMimePartDataSource (mm, this, uid);
        DataHandler dh = new DataHandler(source);
        return dh;
      } catch (Exception e) {
        return null;
      }
      //return new DataHandler(new FileDataSource(f));
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.