I use a the next to put data on 'memory'
ByteArrayOutputStream bytestream =new ByteArrayOutputStream();
DataOutputStream datastream = new DataOutputStream(bytestream);
And the method to 'connect' de 'out' with the 'in' is by mean of pass an array :
ByteArrayInputStream bytestream_in =new ByteArrayInputStream(bytestream.toByteArray());
DataInputStream datastream_in =new DataInputStream(bytestream_in);
Is there any way to do this better ?
Jesus ! The data I have on a file now is in memory ....
Better .... :
bytestream is already in memory
bytestream.toByteArray() creates a newly allocated byte array
If you consider it , it is an additional cost. Is there any way to connect ByteArrayInputStream with ByteArrayOutputStream ??
By other side, if my bytestream grows I must to 'reload ' ByteArrayInputStream and make a new bytestream.toByteArray() ....
I hope now you understand me