how to convert outputstream to bytearrayoutputstream in java
ByteArrayOutputStream bos =newByteArrayOutputStream();//Write the data to the byte array output stream herebyte[] arr = bos.toByteArray();//write the byte stream to the output stream
os.write(arr);