Top Fields Constructors Methods
org.bouncycastle.mail.smime.util

public Class FileBackedMimeBodyPart

extends MimeBodyPart
Class Inheritance
Known Direct Subclasses
org.bouncycastle.mail.smime.SMIMEUtil.WriteOnceFileBackedMimeBodyPart
Imports
javax.mail.MessagingException, javax.mail.internet.InternetHeaders, .MimeBodyPart, java.io.File, .FileOutputStream, .IOException, .InputStream, .OutputStream, java.util.Enumeration

Field Summary

Modifier and TypeField and Description
private final File
private static final int
Inherited from javax.mail.internet.MimeBodyPart:
cachedContentcontentcontentStreamdhheaders

Constructor Summary

AccessConstructor and Description
public
FileBackedMimeBodyPart(File
file containing the body part.
file
)

Create a MimeBodyPart backed by the data in file.

public
FileBackedMimeBodyPart(InputStream
an inputstream containing the body part.
content
,
File
a handle to the backing file to use for storage.
file
)

Create a MimeBodyPart backed by file based on the headers and content data in content.

public
FileBackedMimeBodyPart(InternetHeaders
headers for the body part.
headers
,
InputStream
internal content for the body part.
body
,
File
backing file to use.
file
)

Create a MimeBodyPart backed by file, with the headers given in headers and body content taken from the stream body.

Method Summary

Modifier and TypeMethod and Description
public void
dispose()

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

private static void
private static File
saveStreamToFile(InputStream content, File tempFile)

private static File
saveStreamToFile(InternetHeaders headers, InputStream content, File tempFile)

private static void
private static void
public void
writeTo(OutputStream
the stream to write to
out
)

Overrides javax.mail.internet.MimeBodyPart.writeTo.

Implements javax.mail.Part.writeTo.

Output the body part as an RFC 822 format stream.
Inherited from javax.mail.internet.MimeBodyPart:
addHeaderaddHeaderLineattachFileattachFileattachFileattachFilegetAllHeaderLinesgetAllHeadersgetContentgetContentIDgetContentLanguagegetContentMD5getContentStreamgetContentTypegetDataHandlergetDescriptiongetDispositiongetEncodinggetFileNamegetHeadergetHeadergetInputStreamgetLineCountgetMatchingHeaderLinesgetMatchingHeadersgetNonMatchingHeaderLinesgetNonMatchingHeadersgetRawInputStreamgetSizeisMimeTyperemoveHeadersaveFilesaveFilesetContentsetContentsetContentIDsetContentLanguagesetContentMD5setDataHandlersetDescriptionsetDescriptionsetDispositionsetFileNamesetHeadersetTextsetTextsetTextupdateHeaders

Field Detail

_fileback to summary
private final File _file
BUF_SIZEback to summary
private static final int BUF_SIZE

Constructor Detail

FileBackedMimeBodyPartback to summary
public FileBackedMimeBodyPart(File file) throws MessagingException, IOException

Create a MimeBodyPart backed by the data in file.

Parameters
file:File

file containing the body part.

Exceptions
MessagingException:
an exception occurs parsing file.
IOException:
an exception occurs accessing file.
FileBackedMimeBodyPartback to summary
public FileBackedMimeBodyPart(InputStream content, File file) throws MessagingException, IOException

Create a MimeBodyPart backed by file based on the headers and content data in content.

Parameters
content:InputStream

an inputstream containing the body part.

file:File

a handle to the backing file to use for storage.

Exceptions
MessagingException:
an exception occurs parsing the resulting body part in file.
IOException:
an exception occurs accessing file or content.
FileBackedMimeBodyPartback to summary
public FileBackedMimeBodyPart(InternetHeaders headers, InputStream body, File file) throws MessagingException, IOException

Create a MimeBodyPart backed by file, with the headers given in headers and body content taken from the stream body.

Parameters
headers:InternetHeaders

headers for the body part.

body:InputStream

internal content for the body part.

file:File

backing file to use.

Exceptions
MessagingException:
if the body part can't be produced.
IOException:
if there is an issue reading stream or writing to file.

Method Detail

disposeback to summary
public void dispose() throws IOException

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

Exceptions
IOException:
if streams cannot be closed or the file cannot be deleted.
saveContentToStreamback to summary
private static void saveContentToStream(OutputStream out, InputStream content) throws IOException
saveStreamToFileback to summary
private static File saveStreamToFile(InputStream content, File tempFile) throws IOException
saveStreamToFileback to summary
private static File saveStreamToFile(InternetHeaders headers, InputStream content, File tempFile) throws IOException
writeHeaderback to summary
private static void writeHeader(OutputStream out, String header) throws IOException
writeSeperatorback to summary
private static void writeSeperator(OutputStream out) throws IOException
writeToback to summary
public void writeTo(OutputStream out) throws IOException, MessagingException

Overrides javax.mail.internet.MimeBodyPart.writeTo.

Implements javax.mail.Part.writeTo.

Doc from javax.mail.internet.MimeBodyPart.writeTo.

Output the body part as an RFC 822 format stream.

Parameters
out:OutputStream

Doc from javax.mail.Part.writeTo.

the stream to write to

Exceptions
IOException:
if an error occurs writing to the stream or if an error is generated by the javax.activation layer.
MessagingException:
for other failures