title: Can't read input file, IOException
body: <p>I'm trying to make the array of image buttons in a panel in Jform. For this i want to add the image by giving the path but here is the IO Exception that can't read input file. The error occurs as </p>
  
  <pre><code>Exception in thread "main" javax.imageio.IIOException: Can't read input file!
      at javax.imageio.ImageIO.read(ImageIO.java:1301)
      at serverui.ImageArray.main(ImageArray.java:38)
  </code></pre>
  
  <p>The code is as follow:
      package serverui;</p>
  
  <pre><code>import java.awt.*;
  import java.awt.image.BufferedImage;
  import java.io.*;
  import javax.imageio.ImageIO;
  import javax.swing.*;
  
  public class ImageArray {
      Image[] images;
  
      public ImageArray(Image[] images) {
          this.images = images;
      }
  
      private JPanel getContent() {
          JPanel panel = new JPanel(new GridLayout(0,2,5,5));
          panel.setBackground(Color.green.darker());
          for(int i = 0; i &lt; images.length; i++) {
              ImageIcon icon = new ImageIcon(images[i]);
              JLabel label = new JLabel(icon, JLabel.CENTER);
              panel.add(label);
          }
          return panel;
      }
  
      public static void main(String[] args) throws IOException {
  
          String prefix = "images/";
          String[] ids = { "desktopactive", "desktopoff" };
          String ext = ".png";
          Image[] images = new Image[ids.length];
          for(int i = 0; i &lt; images.length; i++) {
              String path = prefix + ids[i] + ext;
              images[i] = ImageIO.read(new File(path));
          }
  
          ImageArray app = new ImageArray(images);
          JFrame f = new JFrame();
          f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          f.add(app.getContent());
          f.pack();
          f.setLocation(200,200);
          f.setVisible(true);
      }
  }
  </code></pre>