public class TempFilesManager
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BUFFER_SIZE |
static java.lang.String |
DEFAULT_SUFFIX |
static java.lang.String |
NAME_PART_SEPARATOR |
static java.lang.String |
TIMESTAMP_FORMAT |
Constructor and Description |
---|
TempFilesManager(java.io.File tempFolder) |
TempFilesManager(java.io.File tempFolder,
boolean requiresInstanceUniqueness) |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
calculateInstanceUniqueId() |
protected void |
checkTempFolder() |
protected java.io.File |
createTempFileDescriptor() |
protected java.io.File |
createTempFileDescriptor(java.lang.String filenameSnippet) |
protected java.lang.String |
createTempFileName(java.lang.String nameSnippet) |
java.lang.String |
getFileNamePrefix() |
java.lang.String |
getFileNameSuffix() |
java.lang.Long |
getFileSizeLimit()
Returns an optional limit for files that are created.
|
protected java.util.concurrent.atomic.AtomicInteger |
getNextNumericId() |
protected java.io.File |
getTempFolder() |
protected java.lang.String |
getTempFolderName()
Returns the absolute path of the temp folder with forward slash notation.
|
protected java.lang.String |
getTimestamp() |
protected java.lang.String |
getUniqueId() |
long |
removeFilesOlderThan(long timestamp)
Deletes all temporary files in the underlying temp files folder that are older
that the given point in time.
|
protected boolean |
requiresInstanceUniqueness() |
void |
setFileNamePrefix(java.lang.String fileNamePrefix) |
void |
setFileNameSuffix(java.lang.String fileNameSuffix) |
void |
setFileSizeLimit(java.lang.Long limit)
Sets a limit for files that are created.
|
java.io.File |
storeStream(java.io.InputStream inStream)
Creates a temporary file and stores the whole contents of the given stream
into it.
|
java.io.File |
storeStream(java.io.InputStream inStream,
java.lang.String filenameSnippet)
Creates a temporary file and stores the whole contents of the given stream
into it.
|
protected void |
storeStreamToFile(java.io.InputStream inStream,
java.io.File file)
Creates a file for the given file description and stores the whole contents
of the given stream into it.
|
public static final java.lang.String TIMESTAMP_FORMAT
public static final java.lang.String DEFAULT_SUFFIX
public static final java.lang.String NAME_PART_SEPARATOR
public static final int DEFAULT_BUFFER_SIZE
public TempFilesManager(java.io.File tempFolder) throws java.io.IOException
java.io.IOException
public TempFilesManager(java.io.File tempFolder, boolean requiresInstanceUniqueness) throws java.io.IOException
java.io.IOException
public java.lang.String getFileNamePrefix()
public void setFileNamePrefix(java.lang.String fileNamePrefix)
public java.lang.String getFileNameSuffix()
public void setFileNameSuffix(java.lang.String fileNameSuffix)
public java.lang.Long getFileSizeLimit()
public void setFileSizeLimit(java.lang.Long limit)
public java.io.File storeStream(java.io.InputStream inStream) throws java.io.IOException
inStream
- The stream with the data to be stored into the file (must not be null).java.io.IOException
public java.io.File storeStream(java.io.InputStream inStream, java.lang.String filenameSnippet) throws java.io.IOException
inStream
- The stream with the data to be stored into the file (must not be null).java.io.IOException
public long removeFilesOlderThan(long timestamp)
timestamp
- Defines the point in time to compare with.protected void storeStreamToFile(java.io.InputStream inStream, java.io.File file) throws java.io.IOException
inStream
- The stream with the data to be stored into the file (must not be null).file
- The file to which the data of the stream must be written (must not be null).java.io.IOException
protected void checkTempFolder() throws java.io.IOException
java.io.IOException
protected java.io.File createTempFileDescriptor()
protected java.io.File createTempFileDescriptor(java.lang.String filenameSnippet)
protected java.lang.String createTempFileName(java.lang.String nameSnippet)
protected java.lang.String calculateInstanceUniqueId()
protected boolean requiresInstanceUniqueness()
protected java.lang.String getTimestamp()
protected java.lang.String getTempFolderName()
protected java.io.File getTempFolder()
protected java.util.concurrent.atomic.AtomicInteger getNextNumericId()
protected java.lang.String getUniqueId()