I have a stream object, and I want to create and output xml using some kind of xml stream, based on data in my input stream. I haven't done much work with streams, so I am trying to learn how to do this as efficiently as possible. The idea is that I do not want to load the entire input stream in memory, then create the entire output stream in memory because at some point you end up with at least double the size of the input stream taking up memory.
There must be ways so that as data is read in the input stream, the xml stream is built and the data read from the input stream is discarded. Additionally, I would like to architect it so that the xml stream isn't built completely then passed out, but instead the xml stream can be read as it is being built. Does anyone have some code samples, or good resources for learning about this?