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

(spec) File.createTempFile() should make it clear that it doesn't create the temporary directory

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 18
    • 1.4.2, 6u20
    • core-libs
    • b04
    • x86
    • windows_2000, windows_2008

      Name: rmT116609 Date: 04/11/2003


      A DESCRIPTION OF THE REQUEST :
      Please make File.createTempFile attempt to create parent directory.

      On Windows when a directory corresponding to the value of the temp directory property doesn't exist, an Exception is thrown: The system cannot find the path specified.
      Unix doesn't have this problem.

      Instead of throwing this exception it would be nicer to attempt parent.mkdirs 1st, to see if it can actually make this temp file.


      JUSTIFICATION :
      When using some ImageIO providers, they use null as the temp directory hence the property is used, which falsely assumes that the directory already exists. The end result is ImageIO always fails on these systems.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      The parent directory getting created if it doesn't already exist and hence the temp file inside it also getting created.
      an Exception is thrown: The system cannot find the path specified.
      (takes time to find this as the exception gets changed and propagated so many times by ImageIO that the actual cause of the problem is no longer apparent)

      ---------- BEGIN SOURCE ----------
      import java.io.*;

      public class Test {
        public static void main(String[] args) throws IOException {
          File.createTempFile("Test", ".tmp", new File("c:/xxx"));
          System.out.println("Created");
        }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      call new File(System.getProperty("java.io.tmpdir")).mkdirs() before anything ever calls File.createTempFile
      (Review ID: 183674)
      ======================================================================

            bpb Brian Burkhalter
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: