title: Display image from url blackberry
body: <p>This is code i am using to fetch image form url but i am getting blanck screen please help.
  Code For HttpConnection:</p>
  
  <pre><code>StringBuffer raw = new StringBuffer();
      HttpConnection _c = null;
      InputStream _is = null;
      try 
      {
          _c = (HttpConnection)Connector.open(url);
          _c.getHeaderField("Location");          
          int rc = _c.getResponseCode();                      
          if (rc != HttpConnection.HTTP_OK) 
          {
              throw new IOException("HTTP response code: " + rc);
          }           
          _is = _c.openInputStream();
  
          _c.getType();
          int len = (int)_c.getLength();
          {
  
              data = new byte[256];            
              int size = 0;
              while ( -1 != (len = _is.read(data)) ) 
              {
                  raw.append(new String(data, 0, len));
                  size += len;
              }
              String retVal = raw.toString();
              // .alert(retVal);
              return retVal+"URL is"+url;
          }
      } 
      catch (Exception e) 
      {
          throw new IllegalArgumentException("Not an HTTP URL");
      }
      finally 
      {        
          if (_is != null)
              _is.close();
          if (_c != null)
           _c.close();
      }
  </code></pre>
  
  <p>Code to get Image from perticuler URL:</p>
  
  <pre><code> public static Bitmap getImage(String url)
   {
  
       Bitmap bitmap;
       EncodedImage bmp = EncodedImage.createEncodedImage(data, 0, data.length);
       bitmap=bmp.getBitmap();
       return bitmap;
  }
  </code></pre>
  
  <p>Following code i am using to display image on MainScreen:</p>
  
  <pre><code>Bitmap bt=HttpUtils.getImage("http://www.eng.chula.ac.th/files/building.jpg");                  
          BitmapField bmp=new BitmapField(bt);
          bmp.setBitmap(bt);
          add(bmp);
  </code></pre>