You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Nishant Kumar <ni...@itellix.com> on 2004/12/27 09:33:31 UTC

[IO] [PROPOSAL] reader writer

Hi,
	I have a small proposal.

Usage scenario is as follows.

One generates a char array of data using some process and then
immediately this is consumed by another process.

There are two ways of doing the same now.
1. Use a CharArrayWriter to accumulate the data generated in the first
step. convert it to char[] and then consume the char[] in the next step.
2. Use piped reader writer pair.

In both these methods data is written twice. firstly into the
intermediate buffer then onto an array that the second step will
consume.

I have written a class on lines of the piped reader and writer. In this
class there is no intermediate buffer. writer writes the data directly
into the char array passed by the reader in the read method.

Kindly have a look at the class ReaderWriter and ReaderWriterTest (which
gives a usage sample).

Also one more small proposal.
Why don't you have a CharArrayWriter class on the same lines of
ByteArrayOutputStream?

thanks,
nishant