Interface TemporaryDirectory
-
- All Superinterfaces:
java.lang.AutoCloseable,java.io.Closeable
public interface TemporaryDirectory extends java.io.CloseableA 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 Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static TemporaryDirectoryfixed(java.io.File directory)Creates a new temporary directory that uses a fixed directory.java.io.FilegetDirectory()Obtains the directory, only useful for tests.java.io.FilenewFile()Creates a new file in the directory.static TemporaryDirectorynewSystemTemporaryDirectory()Creates a new temporary directory in the system's temporary directory.
-
-
-
Method Detail
-
newFile
java.io.File newFile() throws java.io.IOExceptionCreates 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 theTemporaryDirectoryobjects are closed- Returns:
- a
TemporaryDirectorythat will create files indirectory
-
-