Java Temp Directory Create createTempDir(String subdirectory)

Here you can find the source of createTempDir(String subdirectory)

Description

create Temp Dir

License

Apache License

Declaration

public static Path createTempDir(String subdirectory) throws IOException 

Method Source Code


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

import java.io.IOException;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {
    public static Path createTempDir(String subdirectory) throws IOException {

        String systemTmpDir = System.getProperty("java.io.tmpdir");
        Path tempDirPath = Paths.get(systemTmpDir, subdirectory);
        if (Files.notExists(tempDirPath)) {
            return Files.createDirectory(tempDirPath);
        } else {//  ww w.  ja  v  a  2  s.  c  o m
            return tempDirPath;
        }

    }
}

Related

  1. createTempDir()
  2. createTempDir()
  3. createTempDir(final String prefix)
  4. createTempDir(String prefix)
  5. createTempDir(String suffix)
  6. createTempDirectory()
  7. createTempDirectory()
  8. createTempDirectory()