Package org.jboss.vfs
Class TempDir
- java.lang.Object
-
- org.jboss.vfs.TempDir
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public final class TempDir extends java.lang.Object implements java.io.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 void
close()
Close this directory.java.io.File
createFile(java.lang.String relativePath, java.io.InputStream sourceData)
Create a file within this temporary directory, prepopulating the file from the given input stream.protected void
finalize()
java.io.File
getFile(java.lang.String relativePath)
Get theFile
for a relative path.java.io.File
getRoot()
Get theFile
that represents the root of this temporary directory.
-
-
-
Method Detail
-
getRoot
public java.io.File getRoot() throws java.io.IOException
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:
java.io.IOException
- if the directory was closed at the time of this invocation
-
getFile
public java.io.File getFile(java.lang.String relativePath) throws java.io.IOException
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:
java.io.IOException
- if the directory was closed at the time of this invocation
-
createFile
public java.io.File createFile(java.lang.String relativePath, java.io.InputStream sourceData) throws java.io.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:
java.io.IOException
- if the directory was closed at the time of this invocation or an error occurs
-
close
public void close() throws java.io.IOException
Close this directory. The contents of the directory will be removed.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
- if an I/O error occurs
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
-