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

问题描述:

这是我的代码

{
    @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

Unable to Decode Stream: fileNotFoundException

尝试一下:

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