Java Utililty Methods Temp Folder Create

List of utility methods to do Temp Folder Create

Description

The list of methods to do Temp Folder Create are organized into topic(s).

Method

FilecreateTemporaryDirectory(File baseDirectory)
create Temporary Directory
File f = new File(baseDirectory, UUID.randomUUID().toString());
if (f.mkdirs() == false) {
    throw new IOException(
            MessageFormat.format("error occurred while creating a temporary directory: {0}", f));
return f;
FilegetTempFolder()
get Temp Folder
if (tempFolder == null) {
    tempFolder = File.createTempFile("temp", Long.toString(System.nanoTime()));
    if (!tempFolder.delete()) {
        throw new IOException("Could not delete temp file: " + tempFolder.getAbsolutePath());
    if (!tempFolder.mkdir()) {
        throw new IOException("Could not create temp directory: " + tempFolder.getAbsolutePath());
    tempFolder.deleteOnExit();
return tempFolder;
FilegetTempFolder()
get Temp Folder
if (tempFolder == null) {
    synchronized (LOCK) {
        if (tempFolder == null) {
            try {
                File tempFile = File.createTempFile("IOUtil", "tmp");
                tempFolder = tempFile.getParentFile();
                tempFile.delete();
            } catch (IOException ex) {
...
StringGetTempFolder()
Get Temp Folder
String osname = System.getProperty("os.name").toLowerCase();
File ff = null;
if (osname.startsWith("windows") || System.getProperty("file.separator").equals("\\")
        || osname.startsWith("os/2")) {
    ff = new File("\\tmp", "");
    if (ff == null || !ff.exists())
        ff = new File("\\temp", "");
    if (ff == null || !ff.exists())
...
FilegetTempFolder()
get Temp Folder
return new File(System.getProperty("java.io.tmpdir"), TEST_CASES_LOCATION); 
StringgetTempFolder()
get Temp Folder
File tempFolder = new File(System.getProperty("user.dir") + "\\temp");
if (!tempFolder.exists()) {
    tempFolder.mkdirs();
return tempFolder.getPath() + File.separator;
FilegetTempFolder(String TEMP_FOLDER_NAME)
get Temp Folder
File tempFolder = File.createTempFile(TEMP_FOLDER_NAME, null);
tempFolder.delete();
tempFolder.mkdirs();
if (!tempFolder.exists()) {
    throw new IOException("Failed to create temporary jar file when packaging application for deployment: "
            + tempFolder.getAbsolutePath());
return tempFolder;
...
StringgetTempFolderPath()
get Temp Folder Path
String tempPath = System.getProperty("java.io.tmpdir");
if (tempPath.endsWith(Character.toString(File.separatorChar))) {
    tempPath = tempPath.substring(0, tempPath.length() - 1);
return tempPath;
StringgetTempFolderPath()
get Temp Folder Path
return File.createTempFile("tmp", null).getParent();
StringgetTempPath()
Returns the temporary directory path.
return System.getProperty("java.io.tmpdir");