0

I am developing an Android application in which I downloading files from some servers.

Code:

myURL = new URL("abc.com");

myURLConnection = (HttpURLConnection) myURL.openConnection();

myURLConnection.setRequestMethod("POST");

myURLConnection.setUseCaches(false);
myURLConnection.setDoInput(true);
 myURLConnection.setDoOutput(true);

OutputStream op = new BufferedOutputStream(myURLConnection.getOutputStream());
op.write(tokens.toByteArray());
op.close();

The code line op.write(tokens.toByteArray()); is generating an exception "illegalStateException: Did not write as much data as expected java".

QUESTION:

  1. What is the cause for this type of exception?
  2. What is the coding solution for this issue?

Thank you.

0 Answers0