title: jpg not being overwritten by ImageIO.write()
body: <p>I've made the following example, I can't figure out why it isn't working. </p>
  
  <ul>
  <li>None of my checks are returning false, </li>
  <li>I have read and write permissions, </li>
  <li>the imageIO responds that it has in fact overwritten the image, </li>
  <li>no exceptions are thrown... </li>
  </ul>
  
  <p>but the image still hasn't changed on disk.</p>
  
  <pre><code>import java.awt.image.BufferedImage;
  import java.io.File;
  
  import javax.imageio.ImageIO;
  import javax.swing.JFileChooser;
  import javax.swing.filechooser.FileNameExtensionFilter;
  
  public class example
  {
      public static void main(String[] args)
          {
              try
                  {
                      // load a jpg file
                      File imageFile = getFile();
  
                      // Make a Buffered Image from it
                      BufferedImage img = ImageIO.read(imageFile);
  
                      // for every pixel in the image
                      for (int x = 0; x &lt; img.getWidth(); x++)
                          for (int y = 0; y &lt; img.getHeight(); y++)
                              // check if the RGB integer is an odd number
                              if (img.getRGB(x, y) % 2 != 0)
                                  // make it an even number if it is odd (the OCD god demands it!)
                                  img.setRGB(x, y, img.getRGB(x, y) - 1);
  
                      // Write the OCD friendly version to the file
                      System.out.println("Was overwritten: " + ImageIO.write(img, "jpg", imageFile));
                      System.out.println();
  
                      // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
                      // Select the same file again
                      imageFile = getFile();
  
                      // Make the bufferedImage from it
                      img = ImageIO.read(imageFile);
  
                      // for every pixel in the image
                      for (int x = 0; x &lt; img.getWidth(); x++)
                          for (int y = 0; y &lt; img.getHeight(); y++)
                              // check if the RGB integer is an odd number
                              if (img.getRGB(x, y) % 2 != 0)
                                  {
                                      // Report the failing
                                      System.out.println("It didn't work :(");
                                      // Stop the loop
                                      x = img.getWidth();
                                      y = img.getHeight();
                                  }
                  }
              catch (Exception e)
                  {
                      e.printStackTrace();
                  }
          }
  
      public static File getFile()
          {
              // set up a file chooser that only accepts jpgs
              JFileChooser chooser = new JFileChooser();
              chooser.setFileFilter(new FileNameExtensionFilter("JPG Images only", "jpg"));
  
              // This will represent our loaded file
              File imageFile = null;
  
              // Select a file
              chooser.showOpenDialog(null);
              imageFile = chooser.getSelectedFile();
  
              // Check we can do stuff to this file
              System.out.println("Exists: " + imageFile.exists());
              System.out.println("Can Read: " + imageFile.canRead());
              System.out.println("Can Write: " + imageFile.canWrite());
              System.out.println();
  
              return imageFile;
          }
  }
  </code></pre>