Package com.axelor.file.temp
Class TempFiles
java.lang.Object
com.axelor.file.temp.TempFiles
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclean()Clean up obsolete temporary files from upload directory.static voidThis method can be used to delete temporary file of an incomplete upload.static PathCreate a temporary directorystatic PathcreateTempDir(String prefix) Create a temporary directorystatic PathCreate a temporary file.static PathcreateTempFile(String prefix, String suffix, FileAttribute<?>... attrs) Create a temporary file.static PathfindTempFile(String name) Find a temporary file by the given name created previously.static PathGet the root path to deal with temp file/dirstatic PathGet the path to deal with temp upload file/dir
-
Constructor Details
-
TempFiles
public TempFiles()
-
-
Method Details
-
getTempPath
Get the path to deal with temp upload file/dir- Returns:
- the temp path
-
getRootTempPath
Get the root path to deal with temp file/dir- Returns:
- the root temp path
-
createTempFile
Create a temporary file.- Returns:
- the path to the newly created file
- Throws:
IOException- if an I/O error occurs
-
createTempFile
public static Path createTempFile(String prefix, String suffix, FileAttribute<?>... attrs) throws IOException Create a temporary file.- Parameters:
prefix- the file prefix to usesuffix- the file suffix to useattrs- an optional list of file attributes- Returns:
- the path to the newly created file
- Throws:
IOException- if an I/O error occurs- See Also:
-
findTempFile
Find a temporary file by the given name created previously.- Parameters:
name- name of the temp file- Returns:
- file path
-
createTempDir
Create a temporary directory- Returns:
- the path to the newly created directory
- Throws:
IOException- if an I/O error occurs
-
createTempDir
Create a temporary directory- Parameters:
prefix- the prefix string to be used in generating the directory's name- Returns:
- the path to the newly created directory
- Throws:
IOException- if an I/O error occurs
-
clean
This method can be used to delete temporary file of an incomplete upload.- Parameters:
fileId- the upload file id- Throws:
IOException- if an I/O error occurs
-
clean
Clean up obsolete temporary files from upload directory.- Throws:
IOException- if an I/O error occurs
-