I have developed a java/scala XMPP client app that sends data asynchronously using (say) a `write` method and receives data using a `listener` method. The `listener` method receives data as discrete XMPP message packets and processes them using a `processPacket` method (which I can modify based on what I want to do with the received data)
I want to hook up a 3rd party library that reads data from an `inputstream` and writes to an `outputstream`. Specifically, I want the `inputstream` of the 3rd party library to be emulated using the data received via my `listener` method and the `outputstream` to be emulated by my `write` method.
What would be the easiest way to do this? I know that this requires conversion from a stream to chunks of strings and vice-versa. Some hints would be appreciated.
The XMPP message packet structure is as follows (though this can be changed if needed):
data Have you looked at Scala IO? jesseeichar.github.com/scala-io
以上就是converting streams to blocks of strings and vice-versa的详细内容，更多请关注web前端其它相关文章！