Package org.jboss.vfs
Class TempDir
java.lang.Object
org.jboss.vfs.TempDir
- All Implemented Interfaces:
Closeable
,AutoCloseable
A temporary directory which exists until it is closed, at which time its contents will be removed.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicBoolean
private final TempFileProvider
private final File
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close this directory.createFile
(String relativePath, InputStream sourceData) Create a file within this temporary directory, prepopulating the file from the given input stream.protected void
finalize()
Get theFile
for a relative path.getRoot()
Get theFile
that represents the root of this temporary directory.
-
Field Details
-
provider
-
root
-
open
-
-
Constructor Details
-
TempDir
TempDir(TempFileProvider provider, File root)
-
-
Method Details
-
getRoot
Get theFile
that represents the root of this temporary directory. The returned file is only valid as long as the tempdir exists.- Returns:
- the root file
- Throws:
IOException
- if the directory was closed at the time of this invocation
-
getFile
Get theFile
for a relative path. The returned file is only valid as long as the tempdir exists.- Parameters:
relativePath
- the relative path- Returns:
- the corresponding file
- Throws:
IOException
- if the directory was closed at the time of this invocation
-
createFile
Create a file within this temporary directory, prepopulating the file from the given input stream.- Parameters:
relativePath
- the relative path namesourceData
- the source input stream to use- Returns:
- the file
- Throws:
IOException
- if the directory was closed at the time of this invocation or an error occurs
-
close
Close this directory. The contents of the directory will be removed.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- if an I/O error occurs
-
finalize
-