NullPointerException error occurs while converting byte[] to ImageIcon
<p>I am trying to put byte[] to JLabel on netbeans maven Project. I read some solutions and then implement it for me. However when I start application it gives me error lists such as; </p>

<pre><code>Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at javax.swing.ImageIcon.&lt;init&gt;(ImageIcon.java:228)
    at org.tutev.envanterys.gui.finger.FrmFinger.btnShowImagesActionPerformed(FrmFinger.java:104)
    at org.tutev.envanterys.gui.finger.FrmFinger.access$000(FrmFinger.java:29)
    at org.tutev.envanterys.gui.finger.FrmFinger$1.actionPerformed(FrmFinger.java:55)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
</code></pre>

<p>Could you please kindly help me where is my mistake and how can I avoid this? Here is my code: </p>

<pre><code> try {
            Finger finger = new Finger();
            FingerService fingerService = new FingerService();

            finger = fingerService.getImage(Long.parseLong("1"));

            byte[] image1 = finger.getImage1();

            ByteArrayInputStream bais = new ByteArrayInputStream(image1);
            BufferedImage img = ImageIO.read(bais);

            lblFinger1.setIcon(new ImageIcon(img));

        } catch (IOException ex) {
            Logger.getLogger(FrmFinger.class.getName()).log(Level.SEVERE, null, ex);
        }
</code></pre>

<p>When I debug application I see that <code>byte[]</code> and <code>bais</code> has data but <code>BufferedImage img</code> is <strong>null</strong>.</p>