public class ByteArrayDataSource extends java.lang.Object implements DataSource
Constructor and Description |
---|
ByteArrayDataSource(byte[] data,
java.lang.String type)
Create a ByteArrayDataSource with data from the
specified byte array and with the specified MIME type.
|
ByteArrayDataSource(java.io.InputStream is,
java.lang.String type)
Create a ByteArrayDataSource with data from the
specified InputStream and with the specified MIME type.
|
ByteArrayDataSource(java.lang.String data,
java.lang.String type)
Create a ByteArrayDataSource with data from the
specified String and with the specified MIME type.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getContentType()
Get the MIME content type of the data.
|
java.io.InputStream |
getInputStream()
Return an InputStream for the data.
|
java.lang.String |
getName()
Get the name of the data.
|
java.io.OutputStream |
getOutputStream()
Return an OutputStream for the data.
|
void |
setName(java.lang.String name)
Set the name of the data.
|
public ByteArrayDataSource(java.io.InputStream is, java.lang.String type) throws java.io.IOException
is
- the InputStreamtype
- the MIME typejava.io.IOException
- errors reading the streampublic ByteArrayDataSource(byte[] data, java.lang.String type)
data
- the datatype
- the MIME typepublic ByteArrayDataSource(java.lang.String data, java.lang.String type) throws java.io.IOException
charset
parameter specifying the charset to be used for the
string. If the parameter is not included, the
default charset is used.data
- the Stringtype
- the MIME typejava.io.IOException
- errors reading the Stringpublic java.io.InputStream getInputStream() throws java.io.IOException
getInputStream
in interface DataSource
java.io.IOException
- if no data has been setpublic java.io.OutputStream getOutputStream() throws java.io.IOException
IOException
is always thrown.getOutputStream
in interface DataSource
java.io.IOException
- alwayspublic java.lang.String getContentType()
getContentType
in interface DataSource
public java.lang.String getName()
getName
in interface DataSource
public void setName(java.lang.String name)
name
- the name of this data