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

时间:2016-05-27 12:41:38

标签: java android eclipse

这是我的代码

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

1 个答案:

答案 0 :(得分:0)

试试这个:

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