load Bitmap By Url - Android Graphics

Android examples for Graphics:Bitmap URL

Description

load Bitmap By Url

Demo Code


//package com.java2s;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

public class Main {
    public static Bitmap loadByUrl(String url)
            throws MalformedURLException, IOException {

        InputStream is = new URL(url).openStream();
        BufferedInputStream bis = new BufferedInputStream(is);
        Bitmap bitmap = BitmapFactory.decodeStream(bis);
        return bitmap;
    }//  ww  w. j a v a 2  s. c  o  m
}

Related Tutorials