ByteArrayDataSource (Java EE 5 SDK)

Java

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


javax.mail.util Class ByteArrayDataSource

java.lang.Object
  extended by javax.mail.util.ByteArrayDataSource
所有已实现的接口:
DataSource

public class ByteArrayDataSource
extends Object
implements DataSource

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.

从以下版本开始:
JavaMail 1.4
作者:
John Mani, Bill Shannon, Max Spivak

构造器摘要
ByteArrayDataSource(byte[] data, String type)
          Create a ByteArrayDataSource with data from the specified byte array and with the specified MIME type.
ByteArrayDataSource(InputStream is, String type)
          Create a ByteArrayDataSource with data from the specified InputStream and with the specified MIME type.
ByteArrayDataSource(String data, String type)
          Create a ByteArrayDataSource with data from the specified String and with the specified MIME type.
 
方法摘要
 String getContentType()
          Get the MIME content type of the data.
 InputStream getInputStream()
          Return an InputStream for the data.
 String getName()
          Get the name of the data.
 OutputStream getOutputStream()
          Return an OutputStream for the data.
 void setName(String name)
          Set the name of the data.
 
类方法继承 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造器详细信息

ByteArrayDataSource

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.

参数:
is - the InputStream
type - the MIME type
抛出异常:
IOException - errors reading the stream


ByteArrayDataSource

public ByteArrayDataSource(byte[] data,
                           String type)
Create a ByteArrayDataSource with data from the specified byte array and with the specified MIME type.

参数:
data - the data
type - the MIME type


ByteArrayDataSource

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.

参数:
data - the String
type - the MIME type
抛出异常:
IOException - errors reading the String

方法详细信息

getInputStream

public InputStream getInputStream()
                           throws IOException
Return an InputStream for the data. Note that a new stream is returned each time this method is called.

规范说明:
getInputStream in interface DataSource
返回:
the InputStream
抛出异常:
IOException - if no data has been set

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
Return an OutputStream for the data. Writing the data is not supported; an IOException is always thrown.

规范说明:
getOutputStream in interface DataSource
返回:
an OutputStream
抛出异常:
IOException - always

getContentType

public String getContentType()
Get the MIME content type of the data.

规范说明:
getContentType in interface DataSource
返回:
the MIME type

getName

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

规范说明:
getName in interface DataSource
返回:
the name of this data

setName

public void setName(String name)
Set the name of the data.

参数:
name - the name of this data

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


提交错误或意见

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。深圳电信培训中心.徐海蛟老师教学参考.