title: Javax ImageIO IIOException for apparently no reason
body: <p>Hey all, I have a Java problem. For my senior research class, I'm pretty much finished but I just have to analyze some data in images I generated. I don't want to tag this as homework because it's not part of any required assignment...it's something I came up with on my own to collect results. I wrote a program that compares two images pixel by pixel. It does this for all .bmp files in two directories. Now, my program reads the filenames into a String array and I checked the values of all the filenames, so I know the directories and filenames are being accessed fine initially. Here's the problematic code:</p>
  
  <pre><code>    public static void main(String[]args) throws IOException
  {
      File actualDir = new File("C:\\Users\\Rowe\\Desktop\\testExpect");
      String actualFiles[] = actualDir.list();
      File expectedDir = new File("C:\\Users\\Rowe\\Desktop\\testExpect2");
      String expectedFiles[] = expectedDir.list();
      int[][] stats = new int[actualFiles.length][6];                             // Holds all info
              //Columns, Rows, Total, redMatches, shouldaBeenRed, badRed
      for(int i = 0; i &lt; actualFiles.length; i++)
      {
          BufferedImage actualImage = null;
          System.out.println(actualFiles[i]);   //THIS PRINTS PROPERLY
          System.out.println(System.getProperty("user.dir"));  //FOR TESTING
          actualImage = ImageIO.read(new File("C:\\Users\\Rowe\\Desktop\\testExpect\\"+actualFiles[i]));   //ERROR HERE
  
          BufferedImage expectedImage = null;
          expectedImage = ImageIO.read(new File("C:\\Users\\Rowe\\Desktop\\testExpect2\\"+expectedFiles[i]));  //THIS IMAGE WORKS
  </code></pre>
  
  <p><code>...rest of code</code></p>
  
  <p>Now, when I change the directories to be the same, the program runs, and detects all pixels to be 100% alike (as it should, so I know the program does what I want it to do). Here's the error:</p>
  
  <p><code>Exception in thread "main" javax.imageio.IIOException: Can't read input file!
      at javax.imageio.ImageIO.read(Unknown Source)
      at PixelCompare.main(PixelCompare.java:22)</code></p>
  
  <p>I've tried different directories to no avail. Could it be something about the .bmp files? What could make one set of BMPs read just fine and another set not work? I can open all the required files in other programs, so they're not corrupted. All properties appear to be the same. One directory was hand-made in Gimp (these read fine), and another was generated by a Java-based program. These can be read in Gimp, Paint, Photoshop, etc, but they won't read in my code.</p>
  
  <p>Any help is greatly appreciated, thanks!</p>
  
  <p>Edit: Forgot to use reverted code...I screwed with it then posted some bad version. Revised to show original problem with what is otherwise functional code. To further describe the problem: if you changed both directories to look in testExpect2 folder for the file list in expectedFiles[], it would run successfully. Also, the <code>System.out.println(actualFiles[i]</code> prints the correct filename before the error occurs, so I know the correct file is being read into the String array. </p>