Top Description Inners Fields Constructors Methods
javax.mail.util

public Class ByteArrayDataSource

extends Object
implements DataSource
Class Inheritance
All Implemented Interfaces
javax.activation.DataSource
Imports
java.io.*, javax.activation.*, javax.mail.internet.*

A DataSource backed by a byte array. The byte array may be passed in directly, or may be initialized from an InputStream or a String.
Authors
John Mani, Bill Shannon, Max Spivak
Since
JavaMail 1.4

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private byte[]
private int
private String
private String

Constructor Summary

AccessConstructor and Description
public
ByteArrayDataSource(InputStream
the InputStream
is
,
String
the MIME type
type
)

Create a ByteArrayDataSource with data from the specified InputStream and with the specified MIME type.

public
ByteArrayDataSource(byte[]
the data
data
,
String
the MIME type
type
)

Create a ByteArrayDataSource with data from the specified byte array and with the specified MIME type.

public
ByteArrayDataSource(String
the String
data
,
String
the MIME type
type
)

Create a ByteArrayDataSource with data from the specified String and with the specified MIME type.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the MIME type
getContentType
()

Implements javax.activation.DataSource.getContentType.

Get the MIME content type of the data.
public InputStream

Returns:

the InputStream
getInputStream
()

Implements javax.activation.DataSource.getInputStream.

Return an InputStream for the data.
public String

Returns:

the name of this data
getName
()

Implements javax.activation.DataSource.getName.

Get the name of the data.
public OutputStream
getOutputStream()

Implements javax.activation.DataSource.getOutputStream.

Return an OutputStream for the data.
public void
setName(String
the name of this data
name
)

Set the name of the data.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

databack to summary
private byte[] data
lenback to summary
private int len
nameback to summary
private String name
typeback to summary
private String type

Constructor Detail

ByteArrayDataSourceback to summary
public ByteArrayDataSource(InputStream is, String type) throws IOException

Create a ByteArrayDataSource with data from the specified InputStream and with the specified MIME type. The InputStream is read completely and the data is stored in a byte array.

Parameters
is:InputStream

the InputStream

type:String

the MIME type

Exceptions
IOException:
errors reading the stream
ByteArrayDataSourceback to summary
public ByteArrayDataSource(byte[] data, String type)

Create a ByteArrayDataSource with data from the specified byte array and with the specified MIME type.

Parameters
data:byte[]

the data

type:String

the MIME type

ByteArrayDataSourceback to summary
public ByteArrayDataSource(String data, String type) throws IOException

Create a ByteArrayDataSource with data from the specified String and with the specified MIME type. The MIME type should include a charset parameter specifying the charset to be used for the string. If the parameter is not included, the default charset is used.

Parameters
data:String

the String

type:String

the MIME type

Exceptions
IOException:
errors reading the String

Method Detail

getContentTypeback to summary
public String getContentType()

Implements javax.activation.DataSource.getContentType.

Get the MIME content type of the data.

Returns:String

the MIME type

Annotations
@Override
getInputStreamback to summary
public InputStream getInputStream() throws IOException

Implements javax.activation.DataSource.getInputStream.

Return an InputStream for the data. Note that a new stream is returned each time this method is called.

Returns:InputStream

the InputStream

Annotations
@Override
Exceptions
IOException:
if no data has been set
getNameback to summary
public String getName()

Implements javax.activation.DataSource.getName.

Get the name of the data. By default, an empty string ("") is returned.

Returns:String

the name of this data

Annotations
@Override
getOutputStreamback to summary
public OutputStream getOutputStream() throws IOException

Implements javax.activation.DataSource.getOutputStream.

Return an OutputStream for the data. Writing the data is not supported; an IOException is always thrown.

Returns:OutputStream

Doc from javax.activation.DataSource.getOutputStream.

an OutputStream

Annotations
@Override
Exceptions
IOException:
always
setNameback to summary
public void setName(String name)

Set the name of the data.

Parameters
name:String

the name of this data

javax.mail.util back to summary

pack-priv Class ByteArrayDataSource.DSByteArrayOutputStream

extends ByteArrayOutputStream
Class Inheritance

Field Summary

Inherited from java.io.ByteArrayOutputStream:
bufcount

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public byte[]
public int
Inherited from java.io.ByteArrayOutputStream:
closeresetsizetoByteArraytoStringtoStringtoStringtoStringwritewritewriteByteswriteTo

Constructor Detail

DSByteArrayOutputStreamback to summary
pack-priv DSByteArrayOutputStream()

Method Detail

getBufback to summary
public byte[] getBuf()
getCountback to summary
public int getCount()