BytesMessage (Java EE 5)

Java EE API


javax.jms Interface BytesMessage

All Superinterfaces:
Message

public interface BytesMessage
extends Message

Implements: Message

BytesMessage 对象用于发送包含未解释字节流的消息。它继承自 Message 接口,并添加了字节消息正文。消息的接收者提供该字节的解释。

BytesMessage 方法主要基于 java.io.DataInputStreamjava.io.DataOutputStream 中的方法。

此消息类型用于客户端现有消息格式的编码。如有可能,应改用其他自定义消息类型之一。

尽管 JMS API 允许将消息属性用于字节消息,但一般不使用它们,因为包含属性可能会影响格式。

可以使用用于每种类型的方法显式写入基本类型。它们通常也能作为对象写入。例如,对 BytesMessage.writeInt(6) 的调用等效于 BytesMessage.writeObject(new Integer(6))。这两种形式都提供,因为显式形式对于静态编程很方便,而编译期间类型未知时需要对象形式。

第一次创建消息,并调用 clearBody 时,消息的正文是只写模式。完成了对 reset 的初次调用后,消息正文是只读模式。发送了消息后,发送它的客户端可以保留并修改该消息,而不影响已经发送的消息。同一个消息对象可以发送多次。收到消息后,提供者调用 reset,以便消息正文对于客户端是只读模式。

如果在只读模式中对消息调用 clearBody,则消息正文被清除,并且消息处于只写模式。

如果客户端尝试在只写模式下读取消息,则抛出 MessageNotReadableException

如果客户端尝试在只读模式下写入消息,则抛出 MessageNotWriteableException

英文文档:

A BytesMessage object is used to send a message containing a stream of uninterpreted bytes. It inherits from the Message interface and adds a bytes message body. The receiver of the message supplies the interpretation of the bytes.

The BytesMessage methods are based largely on those found in java.io.DataInputStream and java.io.DataOutputStream.

This message type is for client encoding of existing message formats. If possible, one of the other self-defining message types should be used instead.

Although the JMS API allows the use of message properties with byte messages, they are typically not used, since the inclusion of properties may affect the format.

The primitive types can be written explicitly using methods for each type. They may also be written generically as objects. For instance, a call to BytesMessage.writeInt(6) is equivalent to BytesMessage.writeObject(new Integer(6)). Both forms are provided, because the explicit form is convenient for static programming, and the object form is needed when types are not known at compile time.

When the message is first created, and when clearBody is called, the body of the message is in write-only mode. After the first call to reset has been made, the message body is in read-only mode. After a message has been sent, the client that sent it can retain and modify it without affecting the message that has been sent. The same message object can be sent multiple times. When a message has been received, the provider has called reset so that the message body is in read-only mode for the client.

If clearBody is called on a message in read-only mode, the message body is cleared and the message is in write-only mode.

If a client attempts to read a message in write-only mode, a MessageNotReadableException is thrown.

If a client attempts to write a message in read-only mode, a MessageNotWriteableException is thrown.

Version:
1.1 April 2, 2002
Author:
Mark Hapner, Rich Burridge, Kate Stout
See Also:
Session.createBytesMessage(), MapMessage, Message, ObjectMessage, StreamMessage, TextMessage

Field Summary
 
Fields inherited from interface javax.jms.Message
 
Method Summary
 long
 boolean
 byte
 int
 int
 char
 double
 float
 int
 long
 short
 int
 int
 String
 void
 void
 void
 void
 void
 void
 void
 void
 void
 void
 void
 void
 void
 
Methods inherited from interface javax.jms.Message
 

Method Detail

public long getBodyLength() throws JMSException
当消息处于只读模式时,获取消息正文的字节数。返回的值可用于分配 byte 数组。不管读取消息的指针当前处于什么位置,返回的值都是消息正文的整个长度。
return 消息中的字节数
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法读取消息。
ThrowsMessageNotReadableException: 如果消息是只写模式。
since1.1
英文文档:

getBodyLength

long getBodyLength()
                   throws JMSException
Gets the number of bytes of the message body when the message is in read-only mode. The value returned can be used to allocate a byte array. The value returned is the entire length of the message body, regardless of where the pointer for reading the message is currently located.

Returns:
number of bytes in the message
Throws:
JMSException - if the JMS provider fails to read the message due to some internal error.
MessageNotReadableException - if the message is in write-only mode.
Since:
1.1

public boolean readBoolean() throws JMSException
从字节消息流中读取一个 boolean
return 读取的 boolean
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法读取消息。
ThrowsMessageEOFException: 如果到达不可预料的字节流末尾。
ThrowsMessageNotReadableException: 如果消息是只写模式。
英文文档:

readBoolean

boolean readBoolean()
                    throws JMSException
Reads a boolean from the bytes message stream.

Returns:
the boolean value read
Throws:
JMSException - if the JMS provider fails to read the message due to some internal error.
MessageEOFException - if unexpected end of bytes stream has been reached.
MessageNotReadableException - if the message is in write-only mode.

public byte readByte() throws JMSException
从字节消息流读取一个有符号的 8 位值。
return 字节消息流中的下一个字节,以有符号 8 位 byte 的形式表示
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法读取消息。
ThrowsMessageEOFException: 如果到达不可预料的字节流末尾。
ThrowsMessageNotReadableException: 如果消息是只写模式。
英文文档:

readByte

byte readByte()
              throws JMSException
Reads a signed 8-bit value from the bytes message stream.

Returns:
the next byte from the bytes message stream as a signed 8-bit byte
Throws:
JMSException - if the JMS provider fails to read the message due to some internal error.
MessageEOFException - if unexpected end of bytes stream has been reached.
MessageNotReadableException - if the message is in write-only mode.

public int readUnsignedByte() throws JMSException
从字节消息流读取一个无符号的 8 位数。
return 字节消息流中的下一个字节,它将被解释为一个无符号 8 位数
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法读取消息。
ThrowsMessageEOFException: 如果到达不可预料的字节流末尾。
ThrowsMessageNotReadableException: 如果消息是只写模式。
英文文档:

readUnsignedByte

int readUnsignedByte()
                     throws JMSException
Reads an unsigned 8-bit number from the bytes message stream.

Returns:
the next byte from the bytes message stream, interpreted as an unsigned 8-bit number
Throws:
JMSException - if the JMS provider fails to read the message due to some internal error.
MessageEOFException - if unexpected end of bytes stream has been reached.
MessageNotReadableException - if the message is in write-only mode.

public short readShort() throws JMSException
从字节消息流中读取一个有符号的 16 位数。
return 字节消息流中的下两个字节,解释为一个有符号 16 位数
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法读取消息。
ThrowsMessageEOFException: 如果到达不可预料的字节流末尾。
ThrowsMessageNotReadableException: 如果消息是只写模式。
英文文档:

readShort

short readShort()
                throws JMSException
Reads a signed 16-bit number from the bytes message stream.

Returns:
the next two bytes from the bytes message stream, interpreted as a signed 16-bit number
Throws:
JMSException - if the JMS provider fails to read the message due to some internal error.
MessageEOFException - if unexpected end of bytes stream has been reached.
MessageNotReadableException - if the message is in write-only mode.

public int readUnsignedShort() throws JMSException
从字节消息流中读取一个无符号的 16 位数。
return 字节消息流中的下两个字节,解释为一个无符号 16 位整数
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法读取消息。
ThrowsMessageEOFException: 如果到达不可预料的字节流末尾。
ThrowsMessageNotReadableException: 如果消息是只写模式。
英文文档:

readUnsignedShort

int readUnsignedShort()
                      throws JMSException
Reads an unsigned 16-bit number from the bytes message stream.

Returns:
the next two bytes from the bytes message stream, interpreted as an unsigned 16-bit integer
Throws:
JMSException - if the JMS provider fails to read the message due to some internal error.
MessageEOFException - if unexpected end of bytes stream has been reached.
MessageNotReadableException - if the message is in write-only mode.

public char readChar() throws JMSException
从字节消息流中读取一个 Unicode 字符值。
return 字节消息流中的下两个字节,解释为一个 Unicode 字符
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法读取消息。
ThrowsMessageEOFException: 如果到达不可预料的字节流末尾。
ThrowsMessageNotReadableException: 如果消息是只写模式。
英文文档:

readChar

char readChar()
              throws JMSException
Reads a Unicode character value from the bytes message stream.

Returns:
the next two bytes from the bytes message stream as a Unicode character
Throws:
JMSException - if the JMS provider fails to read the message due to some internal error.
MessageEOFException - if unexpected end of bytes stream has been reached.
MessageNotReadableException - if the message is in write-only mode.

public int readInt() throws JMSException
从字节消息流中读取一个有符号的 32 位整数。
return 字节消息流中的下四个字节,解释为一个 int
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法读取消息。
ThrowsMessageEOFException: 如果到达不可预料的字节流末尾。
ThrowsMessageNotReadableException: 如果消息是只写模式。
英文文档:

readInt

int readInt()
            throws JMSException
Reads a signed 32-bit integer from the bytes message stream.

Returns:
the next four bytes from the bytes message stream, interpreted as an int
Throws:
JMSException - if the JMS provider fails to read the message due to some internal error.
MessageEOFException - if unexpected end of bytes stream has been reached.
MessageNotReadableException - if the message is in write-only mode.

public long readLong() throws JMSException
从字节消息流中读取一个有符号的 64 位整数。
return 字节消息流中的下八个字节,解释为一个 long
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法读取消息。
ThrowsMessageEOFException: 如果到达不可预料的字节流末尾。
ThrowsMessageNotReadableException: 如果消息是只写模式。
英文文档:

readLong

long readLong()
              throws JMSException
Reads a signed 64-bit integer from the bytes message stream.

Returns:
the next eight bytes from the bytes message stream, interpreted as a long
Throws:
JMSException - if the JMS provider fails to read the message due to some internal error.
MessageEOFException - if unexpected end of bytes stream has been reached.
MessageNotReadableException - if the message is in write-only mode.

public float readFloat() throws JMSException
从字节消息流中读取一个 float
return 字节消息流中的下四个字节,解释为一个 float
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法读取消息。
ThrowsMessageEOFException: 如果到达不可预料的字节流末尾。
ThrowsMessageNotReadableException: 如果消息是只写模式。
英文文档:

readFloat

float readFloat()
                throws JMSException
Reads a float from the bytes message stream.

Returns:
the next four bytes from the bytes message stream, interpreted as a float
Throws:
JMSException - if the JMS provider fails to read the message due to some internal error.
MessageEOFException - if unexpected end of bytes stream has been reached.
MessageNotReadableException - if the message is in write-only mode.

public double readDouble() throws JMSException
从字节消息流中读取一个 double
return 字节消息流中的下八个字节,解释为一个 double
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法读取消息。
ThrowsMessageEOFException: 如果到达不可预料的字节流末尾。
ThrowsMessageNotReadableException: 如果消息是只写模式。
英文文档:

readDouble

double readDouble()
                  throws JMSException
Reads a double from the bytes message stream.

Returns:
the next eight bytes from the bytes message stream, interpreted as a double
Throws:
JMSException - if the JMS provider fails to read the message due to some internal error.
MessageEOFException - if unexpected end of bytes stream has been reached.
MessageNotReadableException - if the message is in write-only mode.

public String readUTF() throws JMSException
从字节消息流中读取一个已使用 UTF-8 修改版格式编码的字符串。

有关更多 UTF-8 格式的信息,请参阅 "File System Safe UCS Transformation Format (FSS_UTF)",X/Open Preliminary Specification,X/Open Company Ltd.,文件号:P316。也可在 ISO/IEC 10646,Annex P 中查阅此信息。

return 字节消息流的一个 Unicode 字符串
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法读取消息。
ThrowsMessageEOFException: 如果到达不可预料的字节流末尾。
ThrowsMessageNotReadableException: 如果消息是只写模式。

英文文档:

readUTF

String readUTF()
               throws JMSException
Reads a string that has been encoded using a modified UTF-8 format from the bytes message stream.

For more information on the UTF-8 format, see "File System Safe UCS Transformation Format (FSS_UTF)", X/Open Preliminary Specification, X/Open Company Ltd., Document Number: P316. This information also appears in ISO/IEC 10646, Annex P.

Returns:
a Unicode string from the bytes message stream
Throws:
JMSException - if the JMS provider fails to read the message due to some internal error.
MessageEOFException - if unexpected end of bytes stream has been reached.
MessageNotReadableException - if the message is in write-only mode.

public int readBytes(byte[] value) throws JMSException
从字节消息流中读取一个 byte 数组。

如果数组 value 的长度小于还需要从流中读取的字节数,则应该填满数组。后续调用读取下一个增量,依此类推。

如果流中剩余的字节数小于数组 value 的长度,则应将字节读入数组。读取字节总数的返回值将小于数组的长度,指示流中已无字节可供读取。下一次对流的读取返回 -1。

value 将数据读入的缓冲区
return 读入缓冲区的总字节数,如果由于已到达流末尾而不再有数据,则返回 -1
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法读取消息。
ThrowsMessageNotReadableException: 如果消息是只写模式。

英文文档:

readBytes

int readBytes(byte[] value)
              throws JMSException
Reads a byte array from the bytes message stream.

If the length of array value is less than the number of bytes remaining to be read from the stream, the array should be filled. A subsequent call reads the next increment, and so on.

If the number of bytes remaining in the stream is less than the length of array value, the bytes should be read into the array. The return value of the total number of bytes read will be less than the length of the array, indicating that there are no more bytes left to be read from the stream. The next read of the stream returns -1.

Parameters:
value - the buffer into which the data is read
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached
Throws:
JMSException - if the JMS provider fails to read the message due to some internal error.
MessageNotReadableException - if the message is in write-only mode.

public int readBytes(byte[] value, int length) throws JMSException
读取字节消息流的某一部分。

如果数组 value 的长度小于还需要从流中读取的字节数,则应该填满数组。后续调用读取下一个增量,依此类推。

如果流中剩余的字节数小于数组 value 的长度,则应将字节读入数组。读取字节总数的返回值将小于数组的长度,指示流中已无字节可供读取。下一次对流的读取返回 -1。

如果 length 为负,或者 length 大于数组 value 的长度,则抛出 IndexOutOfBoundsException。在此异常情况下不会从流中读取字节。

value 将数据读入的缓冲区
length 要读取的字节数;必须小于或等于 value.length
return 读入缓冲区的总字节数,如果由于已到达流末尾而不再有数据,则返回 -1
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法读取消息。
ThrowsMessageNotReadableException: 如果消息是只写模式。

英文文档:

readBytes

int readBytes(byte[] value,
              int length)
              throws JMSException
Reads a portion of the bytes message stream.

If the length of array value is less than the number of bytes remaining to be read from the stream, the array should be filled. A subsequent call reads the next increment, and so on.

If the number of bytes remaining in the stream is less than the length of array value, the bytes should be read into the array. The return value of the total number of bytes read will be less than the length of the array, indicating that there are no more bytes left to be read from the stream. The next read of the stream returns -1.

If length is negative, or length is greater than the length of the array value, then an IndexOutOfBoundsException is thrown. No bytes will be read from the stream for this exception case.

Parameters:
value - the buffer into which the data is read
length - the number of bytes to read; must be less than or equal to value.length
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached
Throws:
JMSException - if the JMS provider fails to read the message due to some internal error.
MessageNotReadableException - if the message is in write-only mode.

public void writeBoolean(boolean value) throws JMSException
将一个 boolean 以 1-byte 值形式写入字节消息流。值 true 以值 (byte)1 的形式被写入;值 false 以值 (byte)0 的形式被写入。
value 要写入的 boolean
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法写入消息。
ThrowsMessageNotWriteableException: 如果消息是只读模式。
英文文档:

writeBoolean

void writeBoolean(boolean value)
                  throws JMSException
Writes a boolean to the bytes message stream as a 1-byte value. The value true is written as the value (byte)1; the value false is written as the value (byte)0.

Parameters:
value - the boolean value to be written
Throws:
JMSException - if the JMS provider fails to write the message due to some internal error.
MessageNotWriteableException - if the message is in read-only mode.

public void writeByte(byte value) throws JMSException
将一个 byte 以 1-byte 值形式写入字节消息流。
value 要写入的 byte
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法写入消息。
ThrowsMessageNotWriteableException: 如果消息是只读模式。
英文文档:

writeByte

void writeByte(byte value)
               throws JMSException
Writes a byte to the bytes message stream as a 1-byte value.

Parameters:
value - the byte value to be written
Throws:
JMSException - if the JMS provider fails to write the message due to some internal error.
MessageNotWriteableException - if the message is in read-only mode.

public void writeShort(short value) throws JMSException
将一个 short 以两个字节的形式写入字节消息流,先写高字节。
value 要写入的 short
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法写入消息。
ThrowsMessageNotWriteableException: 如果消息是只读模式。
英文文档:

writeShort

void writeShort(short value)
                throws JMSException
Writes a short to the bytes message stream as two bytes, high byte first.

Parameters:
value - the short to be written
Throws:
JMSException - if the JMS provider fails to write the message due to some internal error.
MessageNotWriteableException - if the message is in read-only mode.

public void writeChar(char value) throws JMSException
将一个 char 以 2-byte 值形式写入字节消息流,先写入高字节。
value 要写入的 char
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法写入消息。
ThrowsMessageNotWriteableException: 如果消息是只读模式。
英文文档:

writeChar

void writeChar(char value)
               throws JMSException
Writes a char to the bytes message stream as a 2-byte value, high byte first.

Parameters:
value - the char value to be written
Throws:
JMSException - if the JMS provider fails to write the message due to some internal error.
MessageNotWriteableException - if the message is in read-only mode.

public void writeInt(int value) throws JMSException
将一个 int 以四个字节的形式写入字节消息流,先写入高字节。
value 要写入的 int
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法写入消息。
ThrowsMessageNotWriteableException: 如果消息是只读模式。
英文文档:

writeInt

void writeInt(int value)
              throws JMSException
Writes an int to the bytes message stream as four bytes, high byte first.

Parameters:
value - the int to be written
Throws:
JMSException - if the JMS provider fails to write the message due to some internal error.
MessageNotWriteableException - if the message is in read-only mode.

public void writeLong(long value) throws JMSException
将一个 long 以八个字节的形式写入字节消息流,先写入高字节。
value 要写入的 long
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法写入消息。
ThrowsMessageNotWriteableException: 如果消息是只读模式。
英文文档:

writeLong

void writeLong(long value)
               throws JMSException
Writes a long to the bytes message stream as eight bytes, high byte first.

Parameters:
value - the long to be written
Throws:
JMSException - if the JMS provider fails to write the message due to some internal error.
MessageNotWriteableException - if the message is in read-only mode.

public void writeFloat(float value) throws JMSException
使用 Float 类中的 floatToIntBits 方法将 float 参数转换为一个 int,然后将该 int 值以 4-byte 值形式写入字节消息流,先写入高字节。
value 要写入的 float
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法写入消息。
ThrowsMessageNotWriteableException: 如果消息是只读模式。
英文文档:

writeFloat

void writeFloat(float value)
                throws JMSException
Converts the float argument to an int using the floatToIntBits method in class Float, and then writes that int value to the bytes message stream as a 4-byte quantity, high byte first.

Parameters:
value - the float value to be written
Throws:
JMSException - if the JMS provider fails to write the message due to some internal error.
MessageNotWriteableException - if the message is in read-only mode.

public void writeDouble(double value) throws JMSException
使用 Double 类中的 doubleToLongBits 方法将 double 参数转换为一个 long,然后将该 long 值以 8-byte 值形式写入字节消息流,先写入高字节。
value 要写入的 double
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法写入消息。
ThrowsMessageNotWriteableException: 如果消息是只读模式。
英文文档:

writeDouble

void writeDouble(double value)
                 throws JMSException
Converts the double argument to a long using the doubleToLongBits method in class Double, and then writes that long value to the bytes message stream as an 8-byte quantity, high byte first.

Parameters:
value - the double value to be written
Throws:
JMSException - if the JMS provider fails to write the message due to some internal error.
MessageNotWriteableException - if the message is in read-only mode.

public void writeUTF(String value) throws JMSException
使用 UTF-8 编码以与机器无关的方式将一个字符串写入字节消息流。

有关更多 UTF-8 格式的信息,请参阅 "File System Safe UCS Transformation Format (FSS_UTF)",X/Open Preliminary Specification,X/Open Company Ltd.,文件号:P316。也可在 ISO/IEC 10646,Annex P 中查阅此信息。

value 要写入的 String
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法写入消息。
ThrowsMessageNotWriteableException: 如果消息是只读模式。

英文文档:

writeUTF

void writeUTF(String value)
              throws JMSException
Writes a string to the bytes message stream using UTF-8 encoding in a machine-independent manner.

For more information on the UTF-8 format, see "File System Safe UCS Transformation Format (FSS_UTF)", X/Open Preliminary Specification, X/Open Company Ltd., Document Number: P316. This information also appears in ISO/IEC 10646, Annex P.

Parameters:
value - the String value to be written
Throws:
JMSException - if the JMS provider fails to write the message due to some internal error.
MessageNotWriteableException - if the message is in read-only mode.

public void writeBytes(byte[] value) throws JMSException
将一个 byte 数组写入字节消息流。
value 要写入的 byte 数组
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法写入消息。
ThrowsMessageNotWriteableException: 如果消息是只读模式。
英文文档:

writeBytes

void writeBytes(byte[] value)
                throws JMSException
Writes a byte array to the bytes message stream.

Parameters:
value - the byte array to be written
Throws:
JMSException - if the JMS provider fails to write the message due to some internal error.
MessageNotWriteableException - if the message is in read-only mode.

public void writeBytes(byte[] value, int offset, int length) throws JMSException
将 byte 数组的某一部分写入字节消息流。
value 要写入的 byte 数组
offset byte 数组中的初始偏移量
length 要使用的字节数
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法写入消息。
ThrowsMessageNotWriteableException: 如果消息是只读模式。
英文文档:

writeBytes

void writeBytes(byte[] value,
                int offset,
                int length)
                throws JMSException
Writes a portion of a byte array to the bytes message stream.

Parameters:
value - the byte array value to be written
offset - the initial offset within the byte array
length - the number of bytes to use
Throws:
JMSException - if the JMS provider fails to write the message due to some internal error.
MessageNotWriteableException - if the message is in read-only mode.

public void writeObject(Object value) throws JMSException
将一个对象写入字节消息流。

此方法仅用于对象化的基本对象类型(IntegerDoubleLong 等)、String 对象和 byte 数组。

value 要写入的 Java 编程语言中的对象(“Java 对象”);它不得为 null
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法写入消息。
ThrowsMessageFormatException: 如果对象是无效类型。
ThrowsMessageNotWriteableException: 如果消息是只读模式。
ThrowsNullPointerException: 如果参数 value 为 null。

英文文档:

writeObject

void writeObject(Object value)
                 throws JMSException
Writes an object to the bytes message stream.

This method works only for the objectified primitive object types (Integer, Double, Long ...), String objects, and byte arrays.

Parameters:
value - the object in the Java programming language ("Java object") to be written; it must not be null
Throws:
JMSException - if the JMS provider fails to write the message due to some internal error.
MessageFormatException - if the object is of an invalid type.
MessageNotWriteableException - if the message is in read-only mode.
NullPointerException - if the parameter value is null.

public void reset() throws JMSException
将消息正文置于只读模式并将字节流重新定位到起始处。
ThrowsJMSException: 如果 JMS 提供者由于某个内部错误无法重置消息。
ThrowsMessageFormatException: 如果消息存在无效的格式。
英文文档:

reset

void reset()
           throws JMSException
Puts the message body in read-only mode and repositions the stream of bytes to the beginning.

Throws:
JMSException - if the JMS provider fails to reset the message due to some internal error.
MessageFormatException - if the message has an invalid format.


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!