Package com.groiss.util
Class ByteArrayDataSource
java.lang.Object
com.groiss.util.ByteArrayDataSource
- All Implemented Interfaces:
javax.activation.DataSource
A DataSource that can be created out of a byte array, a
String
or an
input stream.-
Constructor Summary
ConstructorDescriptionByteArrayDataSource
(byte[] data, String type) Create a DataSource from a byte array.ByteArrayDataSource
(InputStream is, String type) Create a DataSoruce from an input stream.ByteArrayDataSource
(String data, String type) Create a DataSource from aString
. -
Method Summary
Modifier and TypeMethodDescriptionReturns the content type for this data source.Returns anInputStream
for reading from this data source.getName()
Returns the name of the data source.This operation is not supported!
-
Constructor Details
-
ByteArrayDataSource
Create a DataSoruce from an input stream.- Parameters:
is
- InputStream from which the data will be read.type
- Mime-Type of the data (e.g., "application/pdf").
-
ByteArrayDataSource
Create a DataSource from a byte array.- Parameters:
data
- byte array holding the data for this data source. The byte array will not be copied but used directly.type
- Mime-Type of the data (e.g., "application/pdf").
-
ByteArrayDataSource
Create a DataSource from aString
.- Parameters:
data
- String holding the data for this data source.type
- Mime-Type of the data (e.g., "application/pdf").
-
-
Method Details
-
getInputStream
Returns anInputStream
for reading from this data source.- Specified by:
getInputStream
in interfacejavax.activation.DataSource
- Throws:
IOException
-
getOutputStream
This operation is not supported! If you call it, anIOException
will be thrown.- Specified by:
getOutputStream
in interfacejavax.activation.DataSource
- Throws:
IOException
-
getContentType
Returns the content type for this data source.- Specified by:
getContentType
in interfacejavax.activation.DataSource
-
getName
Returns the name of the data source. Current implementation returns always "dummy", because there is no need for a name.- Specified by:
getName
in interfacejavax.activation.DataSource
-