title: How to transform a JPG URL remote Image into a Bitmap?
body: <p>i want to get a remote JPG file from a URL (  <a href="http://www.bbc.co.uk/blogs/spanish/ravsberg_442x330jpg.jpg" rel="nofollow">http://www.bbc.co.uk/blogs/spanish/ravsberg_442x330jpg.jpg</a> ) and have it into a Bitmap.</p>
  
  <p>I'm trying to use this code:</p>
  
  <pre><code>public static Bitmap getBitmapFromURL(String src) {
      try {
          URL url = new URL(src);
          HttpURLConnection connection = (HttpURLConnection) url.openConnection();
          connection.setDoInput(true);
          connection.connect();
          InputStream input = connection.getInputStream();
          Bitmap myBitmap = BitmapFactory.decodeStream(input);
          return myBitmap;
      } catch (IOException e) {e.printStackTrace();}
      return null;
  }
  </code></pre>
  
  <p>But the code is failing on the line: <code>InputStream input = connection.getInputStream();</code></p>
  
  <p>I'm getting this exception:</p>
  
  <pre><code>    03-15 16:08:40.171: WARN/System.err(6526): java.io.FileNotFoundException: http://www.bbc.co.uk/blogs/spanish/ravsberg_442x330jpg.jpg
  03-15 16:08:40.186: WARN/System.err(6526):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:1162)
  03-15 16:08:40.186: WARN/System.err(6526):     at com.Magazine.Util.getBitmapFromURL(Util.java:69)
  03-15 16:08:40.194: WARN/System.err(6526):     at com.Magazine.magazine.getMiniature(magazine.java:32)
  03-15 16:08:40.194: WARN/System.err(6526):     at com.Magazine.MainMenu.generatePortraitGrid(MainMenu.java:141)
  03-15 16:08:40.202: WARN/System.err(6526):     at com.Magazine.MainMenu.onCreate(MainMenu.java:113)
  03-15 16:08:40.210: WARN/System.err(6526):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  03-15 16:08:40.210: WARN/System.err(6526):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
  03-15 16:08:40.210: WARN/System.err(6526):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
  03-15 16:08:40.210: WARN/System.err(6526):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
  03-15 16:08:40.217: WARN/System.err(6526):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
  03-15 16:08:40.217: WARN/System.err(6526):     at android.os.Handler.dispatchMessage(Handler.java:99)
  03-15 16:08:40.217: WARN/System.err(6526):     at android.os.Looper.loop(Looper.java:123)
  03-15 16:08:40.225: WARN/System.err(6526):     at android.app.ActivityThread.main(ActivityThread.java:4627)
  03-15 16:08:40.225: WARN/System.err(6526):     at java.lang.reflect.Method.invokeNative(Native Method)
  03-15 16:08:40.225: WARN/System.err(6526):     at java.lang.reflect.Method.invoke(Method.java:521)
  03-15 16:08:40.225: WARN/System.err(6526):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
  03-15 16:08:40.225: WARN/System.err(6526):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  03-15 16:08:40.233: WARN/System.err(6526):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>