I am trying to convert an OutputStream
to a ByteArrayOutput
Stream. I was unable to find any clear simple answers on how to do this. This question was asked in the title of the question on StackOverflow, but the body of the question aske how to change a ByteArrayStream
to OuputStream
. I have an OutputStream
that is already created and this example given in the answer will not compile!
I have an OutputStream that is already constructed and has a length of 44 bytes called waveHeader. I want to convert that to a ByteArrayOutputStream because I want to be able to change that into a byte[] with waveHeader.ToByteArray() for simplicity in later processes;
Is there a simple type of casting or something that will allow this?
If not then:
Is there a way to construct a pointer to the data in the original OutputStream if it is not possible to convert it?
How would someone go about accessing the data that is contained in the OutputStream?
I am new to JAVA. This is just a hobby for me. Streams In VisualBasic .net where much easier!
OutputStream
into aByteArrayOutputStream
, but you can change the code that gave you the originalOutputStream
to give you aByteArrayOutputStream
instead. – Volscian