Java Temp Directory Get getTempDir()

Here you can find the source of getTempDir()

Description

get temp dir from OS.

License

Apache License

Return

String temp dir

Declaration

public static String getTempDir() 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.*;

public class Main {
    /**/*from www . j a v a  2 s. com*/
     * get temp dir from OS.
     *
     * @return String temp dir
     */
    public static String getTempDir() {
        // default is user home directory
        String tempDir = System.getProperty("user.home");
        try {
            //create a temp file
            File temp = File.createTempFile("A0393939", ".tmp");
            //Get tempropary file path
            String absolutePath = temp.getAbsolutePath();
            tempDir = absolutePath.substring(0, absolutePath.lastIndexOf(File.separator));
        } catch (IOException e) {
        }
        return tempDir;
    }
}

Related

  1. getTempDir()
  2. getTempDir()
  3. getTempDir()
  4. getTempDir()
  5. getTempDir()
  6. getTempDir()
  7. getTempDir()
  8. getTempDir()
  9. getTempDir()