Java Utililty Methods Temp Directory Get

List of utility methods to do Temp Directory Get

Description

The list of methods to do Temp Directory Get are organized into topic(s).

Method

FilegetTempDir()
get Temp Dir
File file = new File("./img");
if (!file.exists()) {
    file.mkdir();
return file;
StringgetTempDir()
get Temp Dir
String defaultTmpDir = System.getProperty("java.io.tmpdir");
if (defaultTmpDir != null && new File(defaultTmpDir).exists()) {
    return defaultTmpDir;
} else {
    return System.getProperty("user.home");
StringgetTempDir()
get temp dir from OS.
String tempDir = System.getProperty("user.home");
try {
    File temp = File.createTempFile("A0393939", ".tmp");
    String absolutePath = temp.getAbsolutePath();
    tempDir = absolutePath.substring(0, absolutePath.lastIndexOf(File.separator));
} catch (IOException e) {
return tempDir;
...
FilegetTempDir()
get Temp Dir
return new File(System.getProperty("java.io.tmpdir") + File.separator + "iristk");
FilegetTempDir()
get Temp Dir
String tmpDirPath = "/tmp/";
if (null != tmpDirPath) {
    File result = new File(tmpDirPath);
    result.mkdirs();
    if (readableDirectory(result)) {
        return result;
return null;
IPathgetTempDir()
get Temp Dir
String tempPath = System.getProperty("java.io.tmpdir");
try {
    tempPath = new java.io.File(tempPath).getCanonicalPath();
} catch (IOException e) {
return new Path(tempPath);
FilegetTempDir()
get Temp Dir
File tempDir = new File(BUFFER_DIR);
if (tempDir.exists())
    return tempDir;
tempDir.mkdir();
return tempDir;
FilegetTempDir(File baseDir)
get Temp Dir
File dir = null;
while (dir == null) {
    if (baseDir != null) {
        dir = new File(baseDir, UUID.randomUUID().toString());
    } else {
        dir = new File(UUID.randomUUID().toString());
    if (dir.exists()) {
...
FilegetTempDir(final String directory, final String prefix, boolean autodelete)
Creates a temporary directory in the given directory with the given prefix.
int num = randomNumberGenerator.nextInt(Integer.MAX_VALUE);
File dir = new File(directory + File.separator + String.format("%s%06d", prefix, num));
while (dir.exists()) {
    num = randomNumberGenerator.nextInt(Integer.MAX_VALUE);
    dir = new File(directory + File.separator + String.format("%s%06d", prefix, num));
dir.mkdirs();
if (autodelete) {
...
StringgetTempDir(Object fileID, String fileName)
get email attachment temp store dir
return new File(TEMP_DIR, fileName).toURI().toString();