24.3 Writing to streams

For target streams, there are also two implementations: ByteStreamWritingMessageHandler and CharacterStreamWritingMessageHandler. Each requires a single constructor argument - OutputStream for byte streams or Writer for character streams, and each provides a second constructor that adds the optional 'bufferSize'. Since both of these ultimately implement the MessageHandler interface, they can be referenced from a channel-adapter configuration as described in more detail in Chapter 6, Channel Adapter.

<bean class="org.springframework.integration.stream.ByteStreamWritingMessageHandler">
	<constructor-arg ref="someOutputStream"/>
	<constructor-arg value="1024"/>
</bean>

<bean class="org.springframework.integration.stream.CharacterStreamWritingMessageHandler">
	<constructor-arg ref="someWriter"/>
</bean>