Problem using ImageIO.read

后端 未结 3 1350
滥情空心
滥情空心 2021-02-13 19:45

Ok I have an Image that I\'m trying to read. Problem is that the Image.read(file) returns NULL.

File file = new File(\"C:\\\\images\\\\image1.jpg\");
if(file.exi         


        
3条回答
  •  死守一世寂寞
    2021-02-13 19:59

    From the Javadocs for ImageIO.read()

    Returns a BufferedImage as the result of decoding a supplied File with an ImageReader chosen automatically from among those currently registered. The File is wrapped in an ImageInputStream. If no registered ImageReader claims to be able to read the resulting stream, null is returned.

    Try creating an ImageInputStream, then pass that onto the ImageIO.read() method, instead of sending the file itself.

提交回复
热议问题