title: Get Image from Url Unable to Decode Stream: fileNotFoundException
body: <p>I know this issue as been ask many times but i've tried many solutions and no one works.</p>
  
  <p>On Android, I'm trying to get an image from URL to put it in an image view.
  Unfortunately, I get the following error :</p>
  
  <pre><code>E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: http:/lorempixel.com/1920/1920/business (No such file or directory)
  </code></pre>
  
  <p>When I try to reach this URL from the browser of the emulator, it works. </p>
  
  <p>I've already tried the following solutions :
  <a href="https://stackoverflow.com/questions/5776851/load-image-from-url">Load image from url</a></p>
  
  <p><a href="https://stackoverflow.com/questions/24535924/how-to-get-image-from-url-website-in-imageview-in-android">How to get image from url website in imageview in android</a></p>
  
  <p><a href="https://stackoverflow.com/questions/18953632/how-to-set-image-from-url-for-imageview">how to set image from url for imageView</a></p>
  
  <p>My actual code is the following :</p>
  
  <pre><code>public class DownloadImage extends AsyncTask&lt;String, Void, Bitmap&gt; {
  
      ImageView imgView;
  
      public DownloadImage(ImageView imgView){
          this.imgView = imgView;
      }
  
      @Override
      protected Bitmap doInBackground(String... urls) {
          return download_Image(urls[0]);
      }
  
      @Override
      protected void onPostExecute(Bitmap result) {
          if (result != null)
              imgView.setImageBitmap(result);
      }
  
  
      private InputStream OpenHttpConnection(String urlString) throws IOException {
          InputStream in = null;
          int response = -1;
  
          URL url = new URL(urlString);
          URLConnection conn = url.openConnection();
  
          if (!(conn instanceof HttpURLConnection))
              throw new IOException("Not an HTTP connection");
  
          try {
              HttpURLConnection httpConn = (HttpURLConnection) conn;
              httpConn.setAllowUserInteraction(false);
              httpConn.setInstanceFollowRedirects(true);
              httpConn.setRequestMethod("GET");
              httpConn.connect();
              response = httpConn.getResponseCode();
              if (response == HttpURLConnection.HTTP_OK) {
                  in = httpConn.getInputStream();
                  Log.e("CON ", "HTTP connection OK");
              }
          } catch (Exception ex) {
              throw new IOException("Error connecting");
          }
          return in;
      }
  
  
      private Bitmap download_Image(String URL) {
          Bitmap bitmap = null;
          InputStream in = null;
          try {
              in = OpenHttpConnection("http://lorempixel.com/1920/1920/business");
              bitmap = BitmapFactory.decodeStream(in);
              in.close();
          } catch (IOException e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
          }
          return bitmap;
  
      }
  }
  </code></pre>
  
  <p>In the main activity my code is : </p>
  
  <pre><code> ImageView img = (ImageView) findViewById(R.id.imageView);
   DownloadImage download = new DownloadImage(img);
   download.execute(url);
  </code></pre>
  
  <p>In the manifest I've added :</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  </code></pre>
  
  <p>What can I do ?</p>