Here you can find the source of getUniqueTempFile(final boolean autoDelete, final File parentFolder, final String suffix)
Parameter | Description |
---|---|
autoDelete | set to true if you want to have the file cleaned up on JVM exit, no guareentee but... |
parentFolder | Where to create the file. When null, uses default temp folder. |
suffix | Suffix for the file. |
Parameter | Description |
---|---|
IOException | The file could not be created. |
public static File getUniqueTempFile(final boolean autoDelete, final File parentFolder, final String suffix) throws IOException
//package com.java2s; //License from project: Apache License import java.io.*; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**/*from w ww .j av a2s.c o m*/ * @param autoDelete set to true if you want to have the file cleaned up on JVM exit, no guareentee but... * @param parentFolder Where to create the file. When null, uses default temp folder. * @param suffix Suffix for the file. * @return A temporary file. * @throws IOException The file could not be created. */ public static File getUniqueTempFile(final boolean autoDelete, final File parentFolder, final String suffix) throws IOException { final File tmpFile = File.createTempFile( "test_" + new SimpleDateFormat("ddMMMyyyy-HHmmss").format(new Date()), suffix, parentFolder); if (autoDelete) { tmpFile.deleteOnExit(); } return tmpFile; } }