Interface TemporaryDirectory

  • All Superinterfaces:
    java.lang.AutoCloseable, java.io.Closeable

    public interface TemporaryDirectory
    extends java.io.Closeable
    A temporary directory is a directory that creates temporary files. Upon close, all temporary files are removed. Whether the directory itself is removed is dependent on the actual implementation.
    • Method Detail

      • newFile

        java.io.File newFile()
                      throws java.io.IOException
        Creates a new file in the directory. This method returns a new file that deleted, recreated, read and written freely by the caller. No assumptions are made on the contents of this file except that it will be deleted it if it still exists when the temporary directory is closed.
        Throws:
        java.io.IOException
      • getDirectory

        java.io.File getDirectory()
        Obtains the directory, only useful for tests.
      • newSystemTemporaryDirectory

        static TemporaryDirectory newSystemTemporaryDirectory()
                                                       throws java.io.IOException
        Creates a new temporary directory in the system's temporary directory. All files created will be created in this directory. The directory will be deleted (as long as all the files in it) when closed.
        Throws:
        java.io.IOException
      • fixed

        static TemporaryDirectory fixed​(java.io.File directory)
        Creates a new temporary directory that uses a fixed directory.
        Parameters:
        directory - the directory that will be returned; this directory won't be deleted when the TemporaryDirectory objects are closed
        Returns:
        a TemporaryDirectory that will create files in directory