Package org.jboss.vfs
Class TempDir
- java.lang.Object
-
- org.jboss.vfs.TempDir
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public final class TempDir extends Object implements Closeable
A temporary directory which exists until it is closed, at which time its contents will be removed.- Author:
- David M. Lloyd
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close this directory.FilecreateFile(String relativePath, InputStream sourceData)Create a file within this temporary directory, prepopulating the file from the given input stream.protected voidfinalize()FilegetFile(String relativePath)Get theFilefor a relative path.FilegetRoot()Get theFilethat represents the root of this temporary directory.
-
-
-
Method Detail
-
getRoot
public File getRoot() throws IOException
Get theFilethat 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
public File getFile(String relativePath) throws IOException
Get theFilefor 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
public File createFile(String relativePath, InputStream sourceData) throws IOException
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
public void close() throws IOExceptionClose this directory. The contents of the directory will be removed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- if an I/O error occurs
-
-