Package org.compiere.util
Class ByteArrayDataSource
java.lang.Object
org.compiere.util.ByteArrayDataSource
- All Implemented Interfaces:
javax.activation.DataSource
A DataSource based on the Java Mail Example.
This class implements a DataSource from:an InputStream
a byte array
a String
This class implements a DataSource from:
- Author:
- John Mani, Bill Shannon, Max Spivak
-
Constructor Summary
ConstructorsConstructorDescriptionByteArrayDataSource(byte[] data, String type) Create a DataSource from a byte arrayByteArrayDataSource(InputStream is, String type) Create a DataSource from an input streamByteArrayDataSource(String stringData, String charSetName, String type) Create a DataSource from a String -
Method Summary
Modifier and TypeMethodDescriptionGet Content TypeGet InputStream for the data.getName()Get Name or Class Name and Content TypeThrows exceptionSet Name
-
Constructor Details
-
ByteArrayDataSource
Create a DataSource from an input stream- Parameters:
is- streamtype- optional MIME type e.g. text/html
-
ByteArrayDataSource
Create a DataSource from a byte array- Parameters:
data- datatype- type e.g. text/html
-
ByteArrayDataSource
Create a DataSource from a String- Parameters:
stringData- contentcharSetName- optional if null/empty uses UTF-8type- optional MIME type e.g. text/html
-
-
Method Details
-
getInputStream
Get InputStream for the data.- Specified by:
getInputStreamin interfacejavax.activation.DataSource- Returns:
- input stream
- Throws:
IOException
-
getOutputStream
Throws exception- Specified by:
getOutputStreamin interfacejavax.activation.DataSource- Returns:
- null
- Throws:
IOException
-
getContentType
Get Content Type- Specified by:
getContentTypein interfacejavax.activation.DataSource- Returns:
- MIME type e.g. text/html
-
setName
Set Name- Parameters:
name- name- Returns:
- this
-
getName
Get Name or Class Name and Content Type- Specified by:
getNamein interfacejavax.activation.DataSource- Returns:
- dummy
-