title: Blank pages in pdf after downloading it from web
body: <p>I am trying to download a PDF file with HttpClient, it is downloading the PDF file but pages are blank. I can see the bytes on console from response if I print them. But when I try to write it to file it is producing a blank file.</p>
  
  <pre><code>FileUtils.writeByteArrayToFile(new File(outputFilePath), bytes);
  </code></pre>
  
  <p>However the file is showing correct size of 103KB and 297KB as expected but its just blank!!</p>
  
  <p>I tried with Output stream as well like:</p>
  
  <pre><code>FileOutputStream fileOutputStream = new FileOutputStream(outFile);
  fileOutputStream.write(bytes);
  </code></pre>
  
  <p>Also tried to write with UTF-8 coding like:</p>
  
  <pre><code>Writer out = new BufferedWriter( new OutputStreamWriter(
                  new FileOutputStream(outFile), "UTF-8"));
          String str = new String(bytes, StandardCharsets.UTF_8);
          try {
              out.write(str);
          } finally {
              out.close();
          }
  </code></pre>
  
  <p>Nothing is working for me. Any suggestion is highly appreciated..</p>
  
  <p>Update: I am using DefaultHttpClient. </p>
  
  <pre><code>HttpGet httpget = new HttpGet(targetURI);
  HttpResponse response = null;
  String htmlContents = null;
  try {
      httpget = new HttpGet(url);
      response = httpclient.execute(httpget);
      InputStreamReader dataStream=new InputStreamReader(response.getEntity().getContent());
      byte[] bytes = IOUtils.toByteArray(dataStream);
  ...
  </code></pre>