On 3/5/07, Nirav <[EMAIL PROTECTED]> wrote:
OK,
Thanks for help!
And atlast can you help me in getting attachment from Normalized Message?
'getAttachment()' method of Normalized Message returns DataHandler, How do I
convert it into byte[] or String object?
From the DataHandler, you can grab an InputStream. ServiceMix even
provides a utility class that contains a method for copying an
InputStream. See
org.apache.servicemix.jbi.util.FileUtil.copyInputStream for more
information.
Below is an example of grabbing an attachment and using the FileUtil
class to copy the InputStream:
if (in.getAttachmentNames() != null && in.getAttachmentNames().size() > 0) {
for (Iterator it = in.getAttachmentNames().iterator(); it.hasNext();) {
String name = (String) it.next();
DataHandler dh = in.getAttachment(name);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
FileUtil.copyInputStream(dh.getInputStream(), baos);
// Do something w/ the baos here
}
}
Bruce
--
perl -e 'print unpack("u30","D0G)[EMAIL
PROTECTED]&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'
Apache Geronimo - http://geronimo.apache.org/
Apache ActiveMQ - http://activemq.org/
Apache ServiceMix - http://servicemix.org/
Castor - http://castor.org/