title: Download image in blackberry and display
body: <p>I use following code to download jpg image and display in blackberry curve 8900 simulator. When I am trying to load my code, it strucks completely and stop responding. Please some one help me.</p>
  
  <pre><code>public DisplayBusinessDetail(String city,Business business)
  {
      AbsoluteFieldManager absoluteFieldManager = new AbsoluteFieldManager();
      absoluteFieldManager.add(new BitmapField(connectServerForImage("http://www.mobileapples.com/Assets/Content/Wallpapers/Blackberry.jpg")),0,0);
      add(absoluteFieldManager);
  }
  
  public static Bitmap connectServerForImage(String url) {
  
        HttpConnection httpConnection = null;
        DataOutputStream httpDataOutput = null;
        InputStream httpInput = null;
        int rc;
  
        Bitmap bitmp = null;
        try {
         httpConnection = (HttpConnection) Connector.open(url);
         rc = httpConnection.getResponseCode();
         if (rc != HttpConnection.HTTP_OK) {
          throw new IOException("HTTP response code: " + rc);
         }
         httpInput = httpConnection.openInputStream();
         InputStream inp = httpInput;
         byte[] b = IOUtilities.streamToBytes(inp);
         EncodedImage hai = EncodedImage.createEncodedImage(b, 0, b.length);
         return hai.getBitmap();
  
        } catch (Exception ex) {
         System.out.println("URL Bitmap Error........" + ex.getMessage());
        } finally {
         try {
          if (httpInput != null)
           httpInput.close();
          if (httpDataOutput != null)
           httpDataOutput.close();
          if (httpConnection != null)
           httpConnection.close();
         } catch (Exception e) {
          e.printStackTrace();
  
         }
        }
        return bitmp;
       }
  </code></pre>
  
  <p>Thank you in advance</p>