title: DataOutputSteam is throwing me a 'java.io.IOException: unexpected end of stream'?
body: <p>I'm trying to make a Request to a WebService from an android application, using HttpUrlConnection. But sometimes it works, and sometimes it does not.</p>
  
  <p>When I try sending this value:</p>
  
  <p>JSON value</p>
  
  <pre><code> {"Calle":"Calle Pérez 105","DetalleDireccion":"","HoraPartida":"May 18, 2014 9:17:10 AM","Numero":0,"PuntoPartidaLat":18.477295994621315,"PuntoPartidaLon":-69.93638522922993,"Sector":"Main Sector"}
  </code></pre>
  
  <p>I got an "unexpected end of stream" Exception in the DataOutputStream close function. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>DataOutputStream printout;
  // String json;
  byte[] bytes;
  DataInputStream input;
  
  URL serverUrl = null;
  try {
      serverUrl = new URL(Config.APP_SERVER_URL + URL);
  } catch (MalformedURLException e) {
      ...
  } 
  
  bytes = json.getBytes();
  try {
  
      httpCon = (HttpURLConnection) serverUrl.openConnection();
      httpCon.setDoOutput(true);
      httpCon.setUseCaches(false);
      httpCon.setFixedLengthStreamingMode(bytes.length);
      httpCon.setRequestProperty("Authorization", tokenType + " "+ accessToken);
      httpCon.setRequestMethod("POST");
      httpCon.setRequestProperty("Content-Type", "application/json");
  
      printout = new DataOutputStream(httpCon.getOutputStream());
      printout.writeBytes(json);
      printout.flush();
      printout.close();
      ...
  }
  </code></pre>