传输网络图片

来源:互联网 发布:淘宝的买家中心在哪里 编辑:程序博客网 时间:2024/05/21 06:42
// 传输网络图片
public Bitmap getPic(String uriPic) {
    URL imageUrl = null;
    Bitmap bitmap = null;
    try {
        imageUrl = new URL(uriPic);
    catch (MalformedURLException e) {
        e.printStackTrace();
    }
    try {
        HttpURLConnection conn = (HttpURLConnection) imageUrl
                .openConnection();
        conn.connect();
        InputStream is = conn.getInputStream();
        bitmap = BitmapFactory.decodeStream(is);
 
        is.close();
 
    catch (IOException e) {
        e.printStackTrace();
    }
    return bitmap;
}
原创粉丝点击