1 16 17 package org.springframework.jms.support.converter; 18 19 import java.io.ByteArrayOutputStream ; 20 21 import javax.jms.BytesMessage ; 22 import javax.jms.JMSException ; 23 24 39 public class SimpleMessageConverter102 extends SimpleMessageConverter { 40 41 public static final int BUFFER_SIZE = 4096; 42 43 44 51 protected byte[] extractByteArrayFromMessage(BytesMessage message) throws JMSException { 52 ByteArrayOutputStream baos = new ByteArrayOutputStream (BUFFER_SIZE); 53 byte[] buffer = new byte[BUFFER_SIZE]; 54 int bufferCount = -1; 55 while ((bufferCount = message.readBytes(buffer)) >= 0) { 56 baos.write(buffer, 0, bufferCount); 57 if (bufferCount < BUFFER_SIZE) { 58 break; 59 } 60 } 61 return baos.toByteArray(); 62 } 63 64 } 65 | Popular Tags |