Class TempFile

  • public final class TempFile
    extends Object
    Interface for creating temporary files. Collects them all into one directory by default.
    • Field Detail


        public static final String JAVA_IO_TMPDIR
        Define a constant for this property as it is sometimes mistypes as "tempdir" otherwise
        See Also:
        Constant Field Values
    • Method Detail

      • createTempFile

        public static File createTempFile​(String prefix,
                                          String suffix)
                                   throws IOException
        Creates a new and empty temporary file. By default, files are collected into one directory and are deleted on exit from the VM, although they can be kept by defining the system property poi.keep.tmp.files (see DefaultTempFileCreationStrategy).

        Don't forget to close all files or it might not be possible to delete them.

        prefix - The prefix to be used to generate the name of the temporary file.
        suffix - The suffix to be used to generate the name of the temporary file.
        The path to the newly created and empty temporary file.
        IOException - If no temporary file could be created.