Java Temp Folder Create getTempFolder()

Here you can find the source of getTempFolder()

Description

get Temp Folder

License

Open Source License

Declaration

public static File getTempFolder() 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {
    private static volatile File tempFolder = null;
    private static final Integer LOCK = 0;

    public static File getTempFolder() {
        if (tempFolder == null) {
            synchronized (LOCK) {
                if (tempFolder == null) {
                    try {
                        File tempFile = File.createTempFile("IOUtil", "tmp");
                        tempFolder = tempFile.getParentFile();
                        tempFile.delete();
                    } catch (IOException ex) {
                        ex.printStackTrace();
                    }/*from  www . ja va  2  s  . c o m*/
                }
            }
        }
        return tempFolder;
    }

    public static File createTempFile(String fileName) {
        try {
            return File.createTempFile("IOUtil", fileName);
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    }
}

Related

  1. createTemporaryDirectory(File baseDirectory)
  2. getTempFolder()
  3. GetTempFolder()
  4. getTempFolder()
  5. getTempFolder()
  6. getTempFolder(String TEMP_FOLDER_NAME)