org.bouncycastle.mail.smime.util

## Class FileBackedMimeBodyPart

- java.lang.Object
- - MimeBodyPart
  - - org.bouncycastle.mail.smime.util.FileBackedMimeBodyPart

    public class FileBackedMimeBodyPart
    extends MimeBodyPart

### Constructor Summary

Constructors
Constructor and Description
`FileBackedMimeBodyPart(java.io.File file)` Create a MimeBodyPart backed by the data in file.
`FileBackedMimeBodyPart(java.io.InputStream content, java.io.File file)` Create a MimeBodyPart backed by file based on the headers and content data in content.
`FileBackedMimeBodyPart(InternetHeaders headers, java.io.InputStream body, java.io.File file)` Create a MimeBodyPart backed by file, with the headers given in headers and body content taken from the stream body.

### Method Summary

Methods
`void` `dispose()` Close off the underlying shared streams and remove the backing file.
`void` `writeTo(java.io.OutputStream out)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### FileBackedMimeBodyPart

    public FileBackedMimeBodyPart(java.io.File file)
                           throws MessagingException,
                                  java.io.IOException

Create a MimeBodyPart backed by the data in file.

Parameters:
  `file` - file containing the body part.
Throws:
  `MessagingException` - an exception occurs parsing file.
  `java.io.IOException` - an exception occurs accessing file.

#### FileBackedMimeBodyPart

    public FileBackedMimeBodyPart(java.io.InputStream content,
                          java.io.File file)
                           throws MessagingException,
                                  java.io.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:
  `MessagingException` - an exception occurs parsing the resulting body part in file.
  `java.io.IOException` - an exception occurs accessing file or content.

#### FileBackedMimeBodyPart

    public FileBackedMimeBodyPart(InternetHeaders headers,
                          java.io.InputStream body,
                          java.io.File file)
                           throws MessagingException,
                                  java.io.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:
  `MessagingException` - if the body part can't be produced.
  `java.io.IOException` - if there is an issue reading stream or writing to file.

### Method Detail

#### writeTo

    public void writeTo(java.io.OutputStream out)
                 throws java.io.IOException,
                        MessagingException

Throws:
  `java.io.IOException`
  `MessagingException`

#### dispose

    public void dispose()
                 throws java.io.IOException

Close off the underlying shared streams and remove the backing file.

Throws:
  `java.io.IOException` - if streams cannot be closed or the file cannot be deleted.