title: android cannot display PDF (name.pdf is of invalid format)
body: <p>I'm downloading a file using volley and I'm not able to open it, it shows this: </p>
  
  <blockquote>
    <p>cannot display PDF (name.pdf is of invalid format)</p>
  </blockquote>
  
  <p>Also mention that service returns an 11kb byte[] and debugging, I'm receiving an 16kb response. The code I'm using is: </p>
  
  <pre><code>InputStreamVolleyRequest request = new InputStreamVolleyRequest(Request.Method.POST, uri,
              new Response.Listener&lt;byte[]&gt;() {
                  @Override
                  public void onResponse(byte[] response) {                        
                      try {
                          if (response!=null) {
  
                              if(Build.VERSION.SDK_INT&gt;22){
                                  requestPermissions(new String[] {"android.permission.WRITE_EXTERNAL_STORAGE","android.permission.READ_EXTERNAL_STORAGE"}, 1);
                              }
  
                              File baseDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
                              baseDir.mkdirs();
                              File carpeta = new File(baseDir + nombre_carpeta);
                              carpeta.mkdirs();
                              File file = new File(baseDir, documento.NombreFichero.replace("\\","/"));
                              try {
                                  BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
                                  bos.write(response);
                                  bos.flush();
                                  bos.close();
                                  Log.d("NEWFILE", file.getAbsolutePath());
                                  Toast.makeText(getActivity(), "Descarga completa.", Toast.LENGTH_LONG).show();
                              } catch (IOException e) {
                                  e.printStackTrace();
                              }
  
                          }
                      } catch (Exception e) {
                          Log.d("KEY_ERROR", "UNABLE TO DOWNLOAD FILE");
                          e.printStackTrace();
                      }
                  }
              } ,new Response.ErrorListener() {
  
          @Override
          public void onErrorResponse(VolleyError error) {
              error.printStackTrace();
          }
      }, (HashMap&lt;String, String&gt;) params);
  
      RequestQueue mRequestQueue = Volley.newRequestQueue(getActivity().getApplicationContext(), new HurlStack());
      mRequestQueue.add(request);
  </code></pre>
  
  <p>Thanks in advance!</p>