public static String createCustomTempDirectory(String customDirectory){
  log.info("Creating a custom temp directory");
  try {
    Path tempDirectory=Files.createTempDirectory(customDirectory);
    File tempFile=tempDirectory.toFile();
    if (tempDirectoryList == null)     tempDirectoryList=new ArrayList<File>();
    tempDirectoryList.add(tempFile);
    createDirectory(tempFile.getCanonicalPath());
    log.info("Finished creating custom temp directory " + tempFile.getCanonicalPath());
    return tempFile.getCanonicalPath();
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

public static String createCustomTempDirectory ( String customDirectory ) { log . info ( "Creating a custom temp directory" ) ; try { Path tempDirectory = Files . createTempDirectory ( customDirectory ) ; File tempFile = tempDirectory . toFile ( ) ; if ( tempDirectoryList == null ) tempDirectoryList = new ArrayList < File > ( ) ; tempDirectoryList . add ( tempFile ) ; createDirectory ( tempFile . getCanonicalPath ( ) ) ; log . info ( "Finished creating custom temp directory " + tempFile . getCanonicalPath ( ) ) ; return tempFile . getCanonicalPath ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
creates a custom temp directory
