title: Exception in thread "main" java.lang.IllegalArgumentException: image == null
body: <p>i used this code to convert an array of bits to bufferedimage but its giving an error </p>
  
  <pre><code> ByteArrayInputStream bais = new ByteArrayInputStream(arr);      
    BufferedImage finale=new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_3BYTE_BGR);
  
    finale=ImageIO.read(bais);
    File outputfile = new File("C:\\Users\\Divya Prakash\\Desktop\\image32.jpg");
    ImageIO.write(finale, "jpg", outputfile);
  </code></pre>
  
  <p>error</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalArgumentException: image == null!
      at javax.imageio.ImageTypeSpecifier.createFromRenderedImage(ImageTypeSpecifier.java:925)
      at javax.imageio.ImageIO.getWriter(ImageIO.java:1592)
      at javax.imageio.ImageIO.write(ImageIO.java:1520)
      at imgpros.Imgpros.main(Imgpros.java:113)
  Java Result: 1
  </code></pre>
  
  <p>how can i remove the error?</p>