Hi, does anyone know a nice way to get the size of an outputStream? I gave it quite some thought already, but (sadly) could not come up with a nice way yet. Thanks for your help, *zoe*
posted 11 years ago
I suppose that depends on what you mean by "size". I'm guessing that most likely you want the total number of bytes which have been writtenthrough the stream. If that's the case, I have a simple class for that:
To use, just wrap a CountingOutputStream around whatever other stream you want to keep count of.
CountingInputStream is a bit more complex, as there are a few more methods to handle (including skip(), mark(), reset()). Similar idea though.