繁体   English   中英

尝试从URL显示图像时无法解码流:fileNotFoundException

[英]Unable to Decode Stream: fileNotFoundException when trying to show an image from URL

这是我的代码

{
    @SuppressLint("NewApi")

    public static Bitmap getbmp(String src)
    {
        Bitmap bm = null;
        try ( InputStream is = new URL( src ).openStream() )
        {
              bm = BitmapFactory.decodeStream( is );
        }
        catch (IOException e)
        {
            e.printStackTrace();
            Log.e("Exception",e.getMessage());
            return null;
        }

     return bm;
     }
}

然后我称之为抛出

无法解码流:fileNotFoundException

尝试这个:

bm = BitmapFactory.decodeStream((InputStream) new URL(src).getContent());

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM