title: Error reading file in java
body: <p>I am trying to read a jpeg image in java and convert it into two dimensional array. Code is as follows</p>
  
  <pre><code>import java.awt.image.BufferedImage;
  import java.io.IOException;
  import java.net.URL;
  import javax.imageio.ImageIO;
  
  public class JpegToArray {
  
  public static void main(String[] args) throws IOException {
  
      URL url = JpegToArray.class.getResource("img/abc.jpg");
      BufferedImage img = ImageIO.read(url);
      @SuppressWarnings("unused")
      int[][] _img = convert_to_2d_Array(img);
  }
  
  private static int[][] convert_to_2d_Array(BufferedImage image) {
      int width = image.getWidth();
      int height = image.getHeight();
  
      int[][] result = new int[height][width];
  
      for (int row = 0; row &lt; height; row++) {
          for (int col = 0; col &lt; width; col++) {
  
              result[row][col] = image.getRGB(col, row);
              System.out.println(result[row][col]);
          }
      }
      return result;
  }
  }
  </code></pre>
  
  <p>When I run ths in Eclipse following error occurs</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalArgumentException: input == null!
  at javax.imageio.ImageIO.read(ImageIO.java:1388)
  at JpegToArray.main(JpegToArray.java:11)
  </code></pre>
  
  <p>What am I doing wrong here?</p>