Code example for URL

Methods: openConnection

0
    public static final String HACK_ICON_URL = "http://www.facebookmobileweb.com/hackbook/img/facebook_icon_large.png";
 
    public static Bitmap getBitmap(String url) {
        Bitmap bm = null;
        try { 
            URL aURL = new URL(url);
            URLConnection conn = aURL.openConnection();
            conn.connect();
            InputStream is = conn.getInputStream();
            BufferedInputStream bis = new BufferedInputStream(is);
            bm = BitmapFactory.decodeStream(new FlushedInputStream(is));
            bis.close();
            is.close();
        } catch (Exception e) {
            e.printStackTrace();
        } finally { 
            if (httpclient != null) {
                httpclient.close();
            } 
        } 
        return bm;