title: IOException - Unexpected end of stream while reading html file
body: <p>I am trying to download the content of a php page (it is just 3 words), but I am getting <code>java.io.IOException: unexpected end of stream</code>. This is the code for downloading:</p>
  
  <pre><code>// Download file list
          String zipListUrl = baseUrl + ziplist;
  
          HttpClient client = new DefaultHttpClient();
          HttpGet request = new HttpGet(zipListUrl);
          try {
              HttpResponse response = client.execute(request);
              // txtResult.setText(HttpHelper.request(response));
              InputStream in = response.getEntity().getContent();
  
              BufferedReader reader = new BufferedReader(
                      new InputStreamReader(in));
  
  
              String line = null;
              String result = null;
              while ((line = reader.readLine()) != null) {
                  // fileNames.add(line);
                  result += line;
              }
              in.close();
              // Turn arraylist into simple array
              // finalFileNames = (String[]) fileNames.toArray();
  
              Log.i(LOG_TAG, /* Arrays.toString(finalFileNames) */result);
  
          } catch (Exception ex) {
              ex.printStackTrace();
              Log.d(LOG_TAG, "Exception ex1  = " + ex.toString());
          }
  </code></pre>
  
  <p>And here is the exception:</p>
  
  <pre><code>08-18 11:11:04.312: W/HttpTransport(3101): unexpected end of stream
  08-18 11:11:04.312: W/HttpTransport(3101): java.io.IOException: unexpected end of stream
  08-18 11:11:04.312: W/HttpTransport(3101):  at libcore.net.http.FixedLengthOutputStream.close(FixedLengthOutputStream.java:58)
  08-18 11:11:04.312: W/HttpTransport(3101):  at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:83)
  08-18 11:11:04.312: W/HttpTransport(3101):  at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:895)
  08-18 11:11:04.312: W/HttpTransport(3101):  at net.zedge.android.api.request.BaseApiRequest.run(BaseApiRequest.java:50)
  08-18 11:11:04.312: W/HttpTransport(3101):  at net.zedge.android.api.request.BaseApiRequest$1.run(BaseApiRequest.java:84)
  08-18 11:11:04.312: W/HttpTransport(3101):  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
  08-18 11:11:04.312: W/HttpTransport(3101):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
  08-18 11:11:04.312: W/HttpTransport(3101):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
  08-18 11:11:04.312: W/HttpTransport(3101):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
  08-18 11:11:04.312: W/HttpTransport(3101):  at java.lang.Thread.run(Thread.java:841)
  08-18 11:11:04.342: W/HttpTransport(3101): unexpected end of stream
  08-18 11:11:04.342: W/HttpTransport(3101): java.io.IOException: unexpected end of stream
  08-18 11:11:04.342: W/HttpTransport(3101):  at libcore.net.http.FixedLengthOutputStream.close(FixedLengthOutputStream.java:58)
  08-18 11:11:04.342: W/HttpTransport(3101):  at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:83)
  08-18 11:11:04.342: W/HttpTransport(3101):  at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:895)
  08-18 11:11:04.342: W/HttpTransport(3101):  at net.zedge.android.api.request.BaseApiRequest.run(BaseApiRequest.java:50)
  08-18 11:11:04.342: W/HttpTransport(3101):  at net.zedge.android.api.request.BaseApiRequest$1.run(BaseApiRequest.java:84)
  08-18 11:11:04.342: W/HttpTransport(3101):  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
  08-18 11:11:04.342: W/HttpTransport(3101):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
  08-18 11:11:04.342: W/HttpTransport(3101):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
  08-18 11:11:04.342: W/HttpTransport(3101):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
  08-18 11:11:04.342: W/HttpTransport(3101):  at java.lang.Thread.run(Thread.java:841)
  </code></pre>
  
  <p>I tried debugging, and the last value of <code>result</code> is this: 
  <code>null&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;&lt;html&gt;&lt;head&gt;&lt;title&gt;404 Not Found&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;h1&gt;Not Found&lt;/h1&gt;&lt;p&gt;The requested URL /ziplist.php was not found on this server.&lt;/p&gt;&lt;p&gt;Additionally, a 404 Not Founderror was encountered while trying to use an ErrorDocument to handle the request.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</code></p>
  
  <p>Any ideas are welcomed!</p>