Java Temp Directory Get getTempDir()

Here you can find the source of getTempDir()

Description

get Temp Dir

License

Open Source License

Return

readable temporary directory (do not delete)

Declaration

public static File getTempDir() 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2005-2012 eBay Inc.// www.j a v  a  2s .c o m
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 *******************************************************************************/

import java.io.File;

public class Main {
    /**
     * @return readable temporary directory (do not delete)
     */
    public static File getTempDir() {
        String tmpDirPath = "/tmp/";// System.getProperty("java.io.tmpdir");
        if (null != tmpDirPath) {
            File result = new File(tmpDirPath);
            result.mkdirs();
            if (readableDirectory(result)) {
                return result;
            }
        }
        return null;
    }

    public static boolean readableDirectory(File dir) {
        return (null != dir) && dir.canRead() && dir.isDirectory();
    }
}

Related

  1. getTempDir()
  2. getTempDir()
  3. getTempDir()
  4. getTempDir()
  5. getTempDir()
  6. getTempDir()
  7. getTempDir()
  8. getTempDir(File baseDir)
  9. getTempDir(final String directory, final String prefix, boolean autodelete)