I try to use writeTo()
method in ByteArrayOutputStream
. Android Studio throw error message:
Cannot resolve method 'writeTo(java.io.ByteArrayOutputStream)'.
I found this method in a tutorial, I would like to use MultipartEntityBuilder
to upload image to server.
@Override
public byte[] getBody() throws AuthFailureError{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
mBuilder.build().writeTo(bos);
} catch (IOException e) {
VolleyLog.e("IOException writing to ByteArrayOutputStream bos, building the multipart request.");
}
return bos.toByteArray();
}