Posted By:
Rakesh_Ranjan
Posted On:
Friday, November 2, 2007 07:11 AM
Hi, I want to encode the text before sending it as body content of TextMessage. The jms provider that i am using is IBM WMQ. I am not much aware of encoding and decoding, so i don't know whether i am doing correct or not. I am doing the following: String bodyContent="some text"; String encodingType="something"; ByteBuffer encodedOutput=null; String encodedStr=null; CharsetEncoder encoder = Charset.forName(encodingType).newEncoder(); try { encodedOutput=encoder.encode(CharBuffer.wrap(bodyContent.toCharArray())); CharBuffer charBuffer = encodedOutput.asCharBuffer(); encodedStr=
More>>
Hi,
I want to encode the text before sending it as body content of TextMessage. The jms provider that i am using is IBM WMQ. I am not much aware of encoding and decoding, so i don't know whether i am doing correct or not. I am doing the following:
String bodyContent="some text";
String encodingType="something";
ByteBuffer encodedOutput=null;
String encodedStr=null;
CharsetEncoder encoder =
Charset.forName(encodingType).newEncoder();
try {
encodedOutput=encoder.encode(CharBuffer.wrap(bodyContent.toCharArray()));
CharBuffer charBuffer = encodedOutput.asCharBuffer();
encodedStr=charBuffer.toString();
} catch (CharacterCodingException e) {
e.printStackTrace();
}
Finally i am setting the
encodedStr
in the message using
setText()
method.
I am sending the message to WMQ using jms client. I am setting the
JMS_IBM_Character_Set
to the CCID corresponding to
encodingType
Is it correct?
Thanks,
RRanjan
<<Less