title: File not fond exception when trying to download apk file
body: <p>I have an android apk file hosted in iis 7 which I would like to download and install from within an android app. I am relying heavily on the code in <a href="https://stackoverflow.com/questions/4967669/android-install-apk-programmatically">this question</a>, but I am getting a fileNotFound exception at <code>InputStream is = con.getInputStream();</code></p>
  
  <p>I am able to download the apk file from within a browser both on my desktop and on the phone (Samsung galaxy Nexus) and I have added the apk mime type to iis. </p>
  
  <p>Here is my code. </p>
  
  <pre><code>protected Void doInBackground(Void... params) {
          try {
              URL url = new URL("http://android.atomweb.net.au/CasLite.apk");
              HttpURLConnection con = (HttpURLConnection) url.openConnection();
  
              con.setRequestMethod("POST");
              con.setDoOutput(true);
              con.connect();
  
              String PATH = Environment.getExternalStorageDirectory() + "/download/";
              File file = new File(PATH);
              file.mkdirs();
              File outputFile = new File(file, "app.apk");
              FileOutputStream fos = new FileOutputStream(outputFile);
  
              InputStream is = con.getInputStream();
  
              byte[] buffer = new byte[1024];
              int len1 = 0;
              while ((len1 = is.read(buffer)) != -1) {
                  fos.write(buffer, 0, len1);
              }
  
              fos.close();
              is.close();
  
              Intent intent = new Intent(Intent.ACTION_VIEW);
              intent.setDataAndType(
                      Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/download/" + "app.apk")),
                      "application/vnd.android.package-archive");
  
              startActivity(intent);
  
          } catch (IOException e) {
              Log.d("Error", e.getLocalizedMessage());
          }
          return null;
  
      }
  </code></pre>
  
  <p>When I post a break point in and look and the connection response code after the connection has been made but before the getInputStream, its 405. </p>