For debugging purposes I would like to dump the content of an input stream into a file while it is processed. The stream is parsed by org.xml.sax.XMLReader
which will consume the data.
I would gess one need a filter to archive this and before writing one my self I wanted to ask if there is a ready made version already.
I work on Android.
What I have:
final org.apache.http.HttpEntity responseEntity = response.getEntity ();
final java.io.InputStream content = responseEntity.getContent ();
final java.io.InputStreamReader contentReader =
new java.io.InputStreamReader (content, "UTF-8");
So I have an java.io.InputStream
and an InputStreamReader
.
A FilterInputStream contains some other input stream, which it uses as its basic source of data, possibly transforming the data along the way or providing additional functionality.
Methods of InputStreamread() - reads one byte of data from the input stream. read(byte[] array) - reads bytes from the stream and stores in the specified array. available() - returns the number of bytes available in the input stream. mark() - marks the position in the input stream up to which data has been read.
A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the input and to support the mark and reset methods. When the BufferedInputStream is created, an internal buffer array is created.
Commons IO to the rescue! Check out TeeInputStream and TeeOutputStream.
Not quite a ready rolled one, but this might be of interest. There is a TeeOutputStream
implementation in the examples.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With