|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
javax.mail.util Class ByteArrayDataSource
java.lang.Objectjavax.mail.util.ByteArrayDataSource
- All Implemented Interfaces:
- DataSource
public class ByteArrayDataSource
- extends Object
- implements DataSource
Implements:
DataSource
byte 数组支持的 DataSource。可以直接传入 byte 数组,也可以根据一个 InputStream 或 String 初始化 byte 数组。
| since |
|
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.
- Since:
- JavaMail 1.4
- Author:
- John Mani, Bill Shannon, Max Spivak
| Constructor Summary | |
|---|---|
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. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public
ByteArrayDataSource(java.io.InputStream is, String type) throws java.io.IOException
使用指定 InputStream 的数据和指定的 MIME 类型创建 ByteArrayDataSource。完整地读取 InputStream 并将数据存储在一个 byte 数组中。
| is | InputStream |
| type | MIME 类型 |
| Throws | java.io.IOException: 读取流时出现错误 |
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.
- Parameters:
is- the InputStreamtype- the MIME type- Throws:
IOException- errors reading the stream
public
ByteArrayDataSource(byte[] data, String type)
使用指定 byte 数组的数据和指定的 MIME 类型创建 ByteArrayDataSource。
| data | 数据 |
| type | MIME 类型 |
ByteArrayDataSource
public ByteArrayDataSource(byte[] data,
String type)
- Create a ByteArrayDataSource with data from the
specified byte array and with the specified MIME type.
- Parameters:
data- the datatype- the MIME type
public
ByteArrayDataSource(String data, String type) throws java.io.IOException
使用指定 String 的数据和指定的 MIME 类型创建 ByteArrayDataSource。MIME 类型应该包含一个 charset 参数,它指定字符串要使用的字符集。如果未包含该参数,则使用默认的字符集。
| data | String |
| type | MIME 类型 |
| Throws | java.io.IOException: 读取 String 时出现错误 |
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
charsetparameter specifying the charset to be used for the string. If the parameter is not included, the default charset is used.- Parameters:
data- the Stringtype- the MIME type- Throws:
IOException- errors reading the String
| Method Detail |
|---|
public java.io.InputStream
getInputStream() throws java.io.IOException
返回数据的 InputStream。注意,每次调用此方法时,都返回一个新流。
| return | InputStream |
| Throws | java.io.IOException: 如果还没有设置任何数据 |
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.
- Specified by:
getInputStreamin interfaceDataSource
- Returns:
- the InputStream
- Throws:
IOException- if no data has been set
public java.io.OutputStream
getOutputStream() throws java.io.IOException
返回数据的 OutputStream。不支持写入数据;总是抛出 IOException。
| Throws | java.io.IOException: 始终 |
getOutputStream
public OutputStream getOutputStream() throws IOException
- Return an OutputStream for the data.
Writing the data is not supported; an
IOExceptionis always thrown. - Specified by:
getOutputStreamin interfaceDataSource
- Returns:
- an OutputStream
- Throws:
IOException- always
public String
getContentType()
获取数据的 MIME 内容类型。
| return | MIME 类型 |
getContentType
public String getContentType()
- Get the MIME content type of the data.
- Specified by:
getContentTypein interfaceDataSource
- Returns:
- the MIME type
public String
getName()
获取数据名称。默认情况下,返回一个空字符串 ("")。
| return | 此数据的名称 |
getName
public String getName()
- Get the name of the data.
By default, an empty string ("") is returned.
- Specified by:
getNamein interfaceDataSource
- Returns:
- the name of this data
public void
setName(String name)
设置数据名称。
| name | 此数据的名称 |
setName
public void setName(String name)
- Set the name of the data.
- Parameters:
name- the name of this data
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!
javax.mail.util.ByteArrayDataSource