I understand that this can be done using wrapper pattern, but i am having a hard time understanding, how does the following code work.
ByteArrayOutputStream bytearray = new ByteArrayOutputStream();
DataOutputStream os = new DataOutputStream(bytearray);
passing ByteArrayOutputStream
reference into the constructor of DataOutputStream
means that the DataOutputStream
gets converted to ByteArrayOutputStream
, but how?
After this, os.writeUTF("String");
How does DataOutputStream
convert to ByteArrayOutputStream
.
What is happening behind the scenes? Can somebody please explain the details.