Package com.randomnoun.common.email
Class ByteArrayDataSource
java.lang.Object
com.randomnoun.common.email.ByteArrayDataSource
- All Implemented Interfaces:
jakarta.activation.DataSource
A DataSource generated from an array of bytes
Used to send arbitrary data through the JavaMail API
- Author:
- knoxg
-
Constructor Summary
ConstructorsConstructorDescriptionByteArrayDataSource
(byte[] data, String name, String contentType) Creates a DataSource from an array of bytes -
Method Summary
Modifier and TypeMethodDescriptionReturns the content type of the DataSourceReturns an InputStream from the DataSourcegetName()
Returns the name of the DataSourceReturns an OutputStream from the DataSource
-
Constructor Details
-
ByteArrayDataSource
Creates a DataSource from an array of bytes- Parameters:
data
- byte[] Array of bytes to convert into a DataSourcename
- String Name of the DataSource (ex: filename)
-
-
Method Details
-
getName
Returns the name of the DataSource- Specified by:
getName
in interfacejakarta.activation.DataSource
- Returns:
- String Name of the DataSource
-
getContentType
Returns the content type of the DataSource- Specified by:
getContentType
in interfacejakarta.activation.DataSource
- Returns:
- String Content type of the DataSource
-
getInputStream
Returns an InputStream from the DataSource- Specified by:
getInputStream
in interfacejakarta.activation.DataSource
- Returns:
- InputStream Array of bytes converted into an InputStream
- Throws:
IOException
-
getOutputStream
Returns an OutputStream from the DataSource- Specified by:
getOutputStream
in interfacejakarta.activation.DataSource
- Returns:
- OutputStream Array of bytes converted into an OutputStream
- Throws:
IOException
-