public final class TempDir
extends java.lang.Object
implements java.io.Closeable
| Modifier and Type | Field and Description |
|---|---|
private java.util.concurrent.atomic.AtomicBoolean |
open |
private TempFileProvider |
provider |
private java.io.File |
root |
| Constructor and Description |
|---|
TempDir(TempFileProvider provider,
java.io.File root) |
| Modifier and Type | Method and 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 the
File for a relative path. |
java.io.File |
getRoot()
Get the
File that represents the root of this temporary directory. |
private final TempFileProvider provider
private final java.io.File root
private final java.util.concurrent.atomic.AtomicBoolean open
TempDir(TempFileProvider provider, java.io.File root)
public java.io.File getRoot()
throws java.io.IOException
File that represents the root of this temporary directory. The returned file is only valid as
long as the tempdir exists.java.io.IOException - if the directory was closed at the time of this invocationpublic java.io.File getFile(java.lang.String relativePath)
throws java.io.IOException
File for a relative path. The returned file is only valid as long as the tempdir exists.relativePath - the relative pathjava.io.IOException - if the directory was closed at the time of this invocationpublic java.io.File createFile(java.lang.String relativePath,
java.io.InputStream sourceData)
throws java.io.IOException
relativePath - the relative path namesourceData - the source input stream to usejava.io.IOException - if the directory was closed at the time of this invocation or an error occurspublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOException - if an I/O error occursprotected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable