ImageIo.read() 返回null

具体代码如下:
imgStr是一个base64字符串
public static String decoderQRCodeForBase64(String imgStr) throws Exception {
if (imgStr == null) {
return "";
}

    BASE64Decoder decoder = new BASE64Decoder();
    byte[] b = decoder.decodeBuffer(imgStr);
    for (int i = 0; i < b.length; ++i) {
        if (b[i] < 0) {// 调整异常数据
            b[i] += 256;
        }
    }

    InputStream input = new ByteArrayInputStream(b);

    String content = decoderQRCode(input);

    return content;

}


public static String decoderQRCode(InputStream input) throws Exception {
    BufferedImage bufImg = null;
    String content = null;

    bufImg = ImageIO.read(input);
    QRCodeDecoder decoder = new QRCodeDecoder();
    content = new String(decoder.decode(new TwoDimensionCodeImage(bufImg)),
            "utf-8");

    return content;
}

在bufImg = ImageIO.read(input);这里读不出来,返回的是null,为什么呢,求大神解答,小白在线等。

捕获下异常,看看运行时有没有异常信息。

首先要看下你是真么调用的么?

b[i]会不会小于-256或者大于256?调试下。byte的范围只能是0~255

图片格式错了,后缀名不代表图片格式,具体怎么解决,我也不知道,因为我也遇到了这个问题