Class FileBackedMimeBodyPart

java.lang.Object
jakarta.mail.BodyPart
jakarta.mail.internet.MimeBodyPart
org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart
All Implemented Interfaces:
jakarta.mail.internet.MimePart, jakarta.mail.Part

public class FileBackedMimeBodyPart extends jakarta.mail.internet.MimeBodyPart
  • Field Summary

    Fields inherited from class jakarta.mail.internet.MimeBodyPart

    cachedContent, content, contentStream, dh, headers

    Fields inherited from class jakarta.mail.BodyPart

    parent

    Fields inherited from interface jakarta.mail.Part

    ATTACHMENT, INLINE
  • Constructor Summary

    Constructors
    Constructor
    Description
    FileBackedMimeBodyPart(jakarta.mail.internet.InternetHeaders headers, InputStream body, File file)
    Create a MimeBodyPart backed by file, with the headers given in headers and body content taken from the stream body.
    Create a MimeBodyPart backed by the data in file.
    Create a MimeBodyPart backed by file based on the headers and content data in content.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close off the underlying shared streams and remove the backing file.
    void
     

    Methods inherited from class jakarta.mail.internet.MimeBodyPart

    addHeader, addHeaderLine, attachFile, attachFile, attachFile, attachFile, getAllHeaderLines, getAllHeaders, getContent, getContentID, getContentLanguage, getContentMD5, getContentStream, getContentType, getDataHandler, getDescription, getDisposition, getEncoding, getFileName, getHeader, getHeader, getInputStream, getLineCount, getMatchingHeaderLines, getMatchingHeaders, getNonMatchingHeaderLines, getNonMatchingHeaders, getRawInputStream, getSize, isMimeType, removeHeader, saveFile, saveFile, setContent, setContent, setContentID, setContentLanguage, setContentMD5, setDataHandler, setDescription, setDescription, setDisposition, setFileName, setHeader, setText, setText, setText, updateHeaders

    Methods inherited from class jakarta.mail.BodyPart

    getParent

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FileBackedMimeBodyPart

      public FileBackedMimeBodyPart(File file) throws jakarta.mail.MessagingException, IOException
      Create a MimeBodyPart backed by the data in file.
      Parameters:
      file - file containing the body part.
      Throws:
      jakarta.mail.MessagingException - an exception occurs parsing file.
      IOException - an exception occurs accessing file.
    • FileBackedMimeBodyPart

      public FileBackedMimeBodyPart(InputStream content, File file) throws jakarta.mail.MessagingException, IOException
      Create a MimeBodyPart backed by file based on the headers and content data in content.
      Parameters:
      content - an inputstream containing the body part.
      file - a handle to the backing file to use for storage.
      Throws:
      jakarta.mail.MessagingException - an exception occurs parsing the resulting body part in file.
      IOException - an exception occurs accessing file or content.
    • FileBackedMimeBodyPart

      public FileBackedMimeBodyPart(jakarta.mail.internet.InternetHeaders headers, InputStream body, File file) throws jakarta.mail.MessagingException, IOException
      Create a MimeBodyPart backed by file, with the headers given in headers and body content taken from the stream body.
      Parameters:
      headers - headers for the body part.
      body - internal content for the body part.
      file - backing file to use.
      Throws:
      jakarta.mail.MessagingException - if the body part can't be produced.
      IOException - if there is an issue reading stream or writing to file.
  • Method Details

    • writeTo

      public void writeTo(OutputStream out) throws IOException, jakarta.mail.MessagingException
      Specified by:
      writeTo in interface jakarta.mail.Part
      Overrides:
      writeTo in class jakarta.mail.internet.MimeBodyPart
      Throws:
      IOException
      jakarta.mail.MessagingException
    • dispose

      public void dispose() throws IOException
      Close off the underlying shared streams and remove the backing file.
      Throws:
      IOException - if streams cannot be closed or the file cannot be deleted.