|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
net.rim.device.api.mime.MIMEOutputStream
public class MIMEOutputStream
Output stream for writing a MIME encoded data stream.
This class implements an output stream which can format output into parts according to the MIME standard.
Note: This class does no direct encoding of the actual data; it assumes that you encode your data before writing it to this stream.
Field Summary | ||
---|---|---|
static String |
ENCODING_7BIT
|
|
static String |
ENCODING_8BIT
|
|
static String |
ENCODING_BASE64
|
|
static String |
ENCODING_BINARY
|
Constructor Summary | ||
---|---|---|
MIMEOutputStream(OutputStream out,
boolean isMultiPart,
String encoding)
Creates a new MIMEOutputStream instance. |
Method Summary | ||
---|---|---|
void |
addContentTypeParameter(String attribute,
String value)
Adds a content type parameter for this part. |
|
void |
addHeaderField(String headerField)
Adds a header field for this part. |
|
void |
close()
Closes this output stream. |
|
void |
flush()
Fluses this stream, writing out any remaining buffered data. |
|
MIMEOutputStream |
getPartOutputStream(boolean isMultiPart,
String encoding)
Creates a new MIME part for this stream. |
|
void |
setContentDescription(String contentDescription)
Sets this part's content description. |
|
void |
setContentID(String contentID)
Sets this part's content ID. |
|
void |
setContentType(String contentType)
Sets this part's content type. |
|
void |
write(byte[] data)
Writes a byte array of data to this stream. |
|
void |
write(byte[] buffer,
int offset,
int length)
Writes some bytes from byte array to this stream. |
|
void |
write(int data)
Writes byte to this stream. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ENCODING_7BIT
public static final String ENCODING_8BIT
public static final String ENCODING_BINARY
public static final String ENCODING_BASE64
Constructor Detail |
---|
public MIMEOutputStream(OutputStream out, boolean isMultiPart, String encoding)
out
- Output stream to contain the data.isMultiPart
- True if this stream is to be a multi-part stream; false
if this stream contains a single part.encoding
- Encoding scheme contained data will use (for example,
"base64"; if null, then this builds a stream using the default, "7bit".Method Detail |
---|
public void setContentType(String contentType) throws IllegalStateException
contentType
- Content type for this part (for example,
"text/plain"); if null, then this part's assumed type is "text/plain".
IllegalStateException
- If this is a multipart message and the
content type does not start with "multipart".public void setContentDescription(String contentDescription)
contentDescription
- Content description for this part; may be null.public void addContentTypeParameter(String attribute, String value)
A content type parameter is a name value pair, associating an attribute with a value.
attribute
- Content type parameter name.value
- Content type parameter value.public void setContentID(String contentID)
contentID
- Content ID for this part; may be null.public void addHeaderField(String headerField)
The header name must begin with "Content-" or this method does nothing. The header field can span several multiple lines as long as line endings are marked with a carriage-return line-feed pair (CRLF).
Examples
"Content-Internal: Message for Internal Use Only" "Content-Internal: Message for Internal Use Only; value=internal"
headerField
- Header field for this part, including header name and value.public MIMEOutputStream getPartOutputStream(boolean isMultiPart, String encoding) throws IllegalStateException
Invoke this method on a multi-part message to create a new part for it. This method retrieves a new MIME output stream you can use to write data into the new part.
isMultiPart
- True if the new part will itself be a multi-part message.encoding
- Content encoding for this new part (for example, "base64").
IllegalStateException
- If this stream is not already a multi-part
message or if this stream has already been closed.public void write(int data) throws IllegalStateException, IOException
Note: you may not use this method to write to a
multi-part message. You should use
getPartOutputStream
to create a new single
part (within this multi-part stream), and then invoke
write
on that.
write
in class OutputStream
data
- Data to write; this method writes the eight lower bits of
this integer, and ignores the higher 24 bits.
IllegalStateException
- If this stream is a multi-part message.
IOException
- If an I/O error occurs; in particular, if this stream
has already been closed.public void write(byte[] data) throws IllegalStateException, IOException
Invoke this method to write all the bytes (in order) from a provided byte array to this output stream.
Note: you may not use this method to write to a
multi-part message. You should use
getPartOutputStream
to create a new single
part (within this multi-part stream), and then invoke
write
on that.
write
in class OutputStream
data
- Data to write.
IllegalStateException
- If this stream is a multi-part message.
IOException
- If an I/O error occurs; in particular, if this stream
has already been closed.OutputStream.write(byte[], int, int)
public void write(byte[] buffer, int offset, int length) throws IllegalStateException, IOException
Invoke this method to write some of the bytes (in order) from a provided byte array to this output stream.
Note: you may not use this method to write to a
multi-part message. You should use
getPartOutputStream
to create a new single
part (within this multi-part stream), and then invoke
write
on that.
write
in class OutputStream
buffer
- Data to write.offset
- First byte from provided array to write.length
- Number of bytes from provided array to write.
IllegalStateException
- If this stream is a multi-part message.
IOException
- If an I/O error occurs; in particular, if this stream
has already been closed.public void flush() throws IOException
Invoke this method to force this stream to write out any data it has currently buffered.
flush
in class OutputStream
IOException
- If an I/O error occurs.public void close() throws IOException
Invoke this method to close this sream and release any system resources it uses.
close
in class OutputStream
IOException
- If an I/O error occurs.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal