Java Temp Directory Create createTempDirectory(File parent, String prefix)

Here you can find the source of createTempDirectory(File parent, String prefix)

Description

Create temporary directory and use specified parent.

License

Open Source License

Parameter

Parameter Description
parent parent
prefix prefix

Exception

Parameter Description

Return

newly create directory

Declaration

public static File createTempDirectory(File parent, String prefix) throws IOException 

Method Source Code


//package com.java2s;

import java.io.File;

import java.io.IOException;

import java.nio.file.Files;

public class Main {
    /**/*from ww w. ja v a2  s .c om*/
     * Create temporary directory and use specified parent. If parent is <code>null</code> then use 'java.io.tmpdir'.
     *
     * @param parent
     *         parent
     * @param prefix
     *         prefix
     * @return newly create directory
     * @throws java.io.IOException
     *         if creation of new directory failed
     * @deprecated - Use Files.createTempDirectory
     */
    public static File createTempDirectory(File parent, String prefix) throws IOException {
        if (parent == null) {
            parent = new File(System.getProperty("java.io.tmpdir"));
        }
        return Files.createTempDirectory(parent.toPath(), prefix).toFile();
    }

    /**
     * Create temporary directory and use 'java.io.tmpdir' as parent.
     *
     * @param prefix
     *         prefix, may not be <code>null</code> and must be at least three characters long
     * @return newly create directory
     * @throws java.io.IOException
     *         if creation of new directory failed
     * @deprecated - Use Files.createTempDirectory
     */
    public static File createTempDirectory(String prefix) throws IOException {
        return createTempDirectory(null, prefix);
    }
}

Related

  1. createTempDir(String subdirectory)
  2. createTempDir(String suffix)
  3. createTempDirectory()
  4. createTempDirectory()
  5. createTempDirectory()
  6. createTempDirectory(String prefix)
  7. createTempDirectory(String prefix)
  8. makeTempDir()
  9. makeTempDir(String name)