Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6438508

ImageIO.write() creates an empty file even when the given format is not supported by ImageIO

XMLWordPrintable

    • b20
    • generic
    • generic
    • Verified

      I am creating a buffered image with some 2D graphics and trying to write it as TIFF image using ImageIO. I am calling ImageIO.write(bimg, "tiff", File). This operation should fail since there is no tiff plugin available in ImageIO. This works as expected where write() method returns false.

      But I am surprised to see an empty file being created in the location that I have given. Say if my output file is output.tif, I see a '0' byte file being created by the write() method. This is misleading since it appears as if write() operation is doing some writing and it failed for some reasons. We should not be creating any empty file when the format is not supported.

      This is reproducible on Tiger as well as Mustang. This is reproducible on all platforms.

      I have attached a sample test. Execute the sample test. If you see an 'output.tif' file in the directory where you executed this test, the bug is reproduced.

            bae Andrew Brygin
            pmohansunw Praveen Mohan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: