1

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();
}
plaidshirt
  • 5,189
  • 19
  • 91
  • 181
  • you can send `File` to server. – Devendra Singh May 25 '16 at 12:50
  • `I found this method in a tutorial` – greenapps May 25 '16 at 13:00
  • @DevendraSingh : That is okay, but causes a lot error messages on that way. That is because I would like to use `MultipartEntity`. – plaidshirt May 25 '16 at 13:26
  • using `MultipartEntity` you can send `file` or [Check here](http://stackoverflow.com/questions/20798837/android-sending-image-to-server-via-multipartentity-setting-content-type) and [Here](http://www.codepuppet.com/2013/03/26/android-uploading-a-file-to-a-php-server/) – Devendra Singh May 25 '16 at 13:29

0 Answers0