org.gcube.datatransformation.datatransformationlibrary.tmpfilemanagement
Class TempFileManager

java.lang.Object
  extended by org.gcube.datatransformation.datatransformationlibrary.tmpfilemanagement.TempFileManager

public class TempFileManager
extends Object

Author:
Dimitris Katris, NKUA Utility class which facilitates temporary file management. Each temporary file created under the DTSTMPDIR is garbage collected by a GarbageCollector instance.

Field Summary
static String DTSExtention
          The file extention of DTS temporary files.
static String DTSTMPDIR
          The root directory under which the TempFileManager stores files.
static boolean win
          Boolean that denotes if the TempFileManager runs under windows OS.
 
Constructor Summary
TempFileManager()
           
 
Method Summary
static void clearTemporaryDirectory()
          Deletes all files contained under the DTSTMPDIR.
static String genarateTempSubDir()
          Creates a sub-directory under the DTSTMPDIR directory.
static String generateTempFileName(String tmpSubDir)
          Generates a file name under the DTSTMPDIR/tmpSubDir directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DTSTMPDIR

public static final String DTSTMPDIR
The root directory under which the TempFileManager stores files.


DTSExtention

public static final String DTSExtention
The file extention of DTS temporary files.

See Also:
Constant Field Values

win

public static boolean win
Boolean that denotes if the TempFileManager runs under windows OS.

Constructor Detail

TempFileManager

public TempFileManager()
Method Detail

generateTempFileName

public static String generateTempFileName(String tmpSubDir)
                                   throws Exception

Generates a file name under the DTSTMPDIR/tmpSubDir directory.

If tmpSubDir is null then this method creates a new one.

Parameters:
tmpSubDir - The sub-directory name.
Returns:
The temporary file name.
Throws:
Exception - If tmpSubDir is null and there was a failure at creating a random sub-directory.

genarateTempSubDir

public static String genarateTempSubDir()
                                 throws Exception
Creates a sub-directory under the DTSTMPDIR directory.

Returns:
The name of the new sub-directory.
Throws:
Exception - If the sub-directory could not be created.

clearTemporaryDirectory

public static void clearTemporaryDirectory()
Deletes all files contained under the DTSTMPDIR.



Copyright © 2013. All Rights Reserved.