Package de.xima.fc.common.file
Class TempFileCreators
- java.lang.Object
-
- de.xima.fc.common.file.TempFileCreators
-
public final class TempFileCreators extends Object
Factory for temporary files creators. A temporary file creator is a supplier that, when called, creates a temporary file and returns its path.- Since:
- 8.3.0
- Author:
- XIMA MEDIA GmbH
-
-
Constructor Summary
Constructors Constructor Description TempFileCreators()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ISerializableThrowingSupplier<Path>newTempFileCreator()Gets a creators that creates temporary files in the default temporary directory.static ISerializableThrowingSupplier<Path>newTempFileCreator(String folder)Gets a creators that creates temporary files in the given folder.static ISerializableThrowingSupplier<Path>newTempFileCreator(String prefix, String suffix)Gets a creators that creates temporary files in the default temporary directory, but with the given prefix and suffix for the file name.static ISerializableThrowingSupplier<Path>newTempFileCreator(String folder, String prefix, String suffix)Gets a creators that creates temporary files in the given folder, and with the given prefix and suffix for the file name.static ISerializableThrowingSupplier<Path>newTempFileCreator(Path folder)Gets a creators that creates temporary files in the given folder.static ISerializableThrowingSupplier<Path>newTempFileCreator(Path folder, String prefix, String suffix)Gets a creators that creates temporary files in the given folder, and with the given prefix and suffix for the file name.static AutoCloseableWrapper<ISerializableThrowingSupplier<Path>,IOException>withNewTempFolder(String folderPrefix, String filePrefix, String fileSuffix)Creates a new temporary folder within the default temporary folder and returns a creator that creates temporary files in that new temporary folder.static AutoCloseableWrapper<ISerializableThrowingSupplier<Path>,IOException>withNewTempFolder(Path folder, String folderPrefix, String filePrefix, String fileSuffix)Creates a new temporary folder within the given folder and returns a creator that creates temporary files in that new temporary folder.
-
-
-
Method Detail
-
newTempFileCreator
public static ISerializableThrowingSupplier<Path> newTempFileCreator()
Gets a creators that creates temporary files in the default temporary directory.- Returns:
- The temporary file creator.
-
newTempFileCreator
public static ISerializableThrowingSupplier<Path> newTempFileCreator(String prefix, String suffix)
Gets a creators that creates temporary files in the default temporary directory, but with the given prefix and suffix for the file name.- Parameters:
prefix- The prefix for the file name.suffix- The suffix for the file name.- Returns:
- The temporary file creator.
-
newTempFileCreator
public static ISerializableThrowingSupplier<Path> newTempFileCreator(Path folder)
Gets a creators that creates temporary files in the given folder.- Parameters:
folder- The folder in which to create the temporary files.- Returns:
- The temporary file creator.
-
newTempFileCreator
public static ISerializableThrowingSupplier<Path> newTempFileCreator(String folder)
Gets a creators that creates temporary files in the given folder.- Parameters:
folder- The folder in which to create the temporary files.- Returns:
- The temporary file creator.
-
newTempFileCreator
public static ISerializableThrowingSupplier<Path> newTempFileCreator(Path folder, String prefix, String suffix)
Gets a creators that creates temporary files in the given folder, and with the given prefix and suffix for the file name.- Parameters:
folder- The folder in which to create the temporary files.prefix- The prefix for the file name.suffix- The suffix for the file name.- Returns:
- The temporary file creator.
-
newTempFileCreator
public static ISerializableThrowingSupplier<Path> newTempFileCreator(String folder, String prefix, String suffix)
Gets a creators that creates temporary files in the given folder, and with the given prefix and suffix for the file name.- Parameters:
folder- The folder in which to create the temporary files.prefix- The prefix for the file name.suffix- The suffix for the file name.- Returns:
- The temporary file creator.
-
withNewTempFolder
public static AutoCloseableWrapper<ISerializableThrowingSupplier<Path>,IOException> withNewTempFolder(String folderPrefix, String filePrefix, String fileSuffix) throws IOException
Creates a new temporary folder within the default temporary folder and returns a creator that creates temporary files in that new temporary folder. The temporary folder is deleted when the wrapper is closed.- Parameters:
folderPrefix- The prefix for the temporary folder name.filePrefix- The prefix for the temporary file names.fileSuffix- The suffix for the temporary file names.- Returns:
- A wrapper around a temporary file creator that creates temporary files in the new temporary folder.
- Throws:
IOException- If an I/O error occurs.
-
withNewTempFolder
public static AutoCloseableWrapper<ISerializableThrowingSupplier<Path>,IOException> withNewTempFolder(Path folder, String folderPrefix, String filePrefix, String fileSuffix) throws IOException
Creates a new temporary folder within the given folder and returns a creator that creates temporary files in that new temporary folder. The temporary folder is deleted when the wrapper is closed.- Parameters:
folderPrefix- The prefix for the temporary folder name.filePrefix- The prefix for the temporary file names.fileSuffix- The suffix for the temporary file names.- Returns:
- A wrapper around a temporary file creator that creates temporary files in the new temporary folder.
- Throws:
IOException- If an I/O error occurs.
-
-