Class TemporaryFileResource
java.lang.Object
io.micronaut.core.io.file.TemporaryFileResource
- All Implemented Interfaces:
Closeable, AutoCloseable
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
TemporaryFileResource
Create a new file resource. Ownership of the path is transferred to the resource.- Parameters:
path- The path
-
-
Method Details
-
getPath
Get the path.- Returns:
- The path
- Throws:
IllegalStateException- if this resource is closed or has been moved
-
moveResource
Move this resource. The returned resource will have ownership of the path, and the original resource will lose ownership, meaning it is essentially closed. No actual file system operation is done.- Returns:
- The new resource managing this path
- Throws:
IllegalStateException- if this resource is already closed or has been moved
-
moveFile
Move this file to a new location. This resource loses ownership of the file, you'll have to manage it from now on.- Parameters:
destination- The destination to move to- Throws:
IOException- If the file cannot be moved. Note that the file will be deleted in this case, the resource still becomes invalid
-
isOpen
public boolean isOpen()Check whether this resource is still open and has ownership of the path.- Returns:
trueif this resource is still open
-
close
Close this resource, deleting the underlying file. If this resource is already closed or has been moved, this method does nothing.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- Failure deleting the file
-