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:
- What is the cause for this type of exception?
- What is the coding solution for this issue?
Thank you.