Créer un fichier temporaire dans un répertoire spécifique

Author:

 fichier, temporaire, java
Download

 
import java.io.File;
import java.io.IOException;
 
public class Fichier_TempPath
 {
 
  public static void main(String[] args) throws IOException
  	 {
    File fichier = null;
    File rep = new File("D:/");
    fichier = File.createTempFile("temp", ".txtTmp", rep);
 
    // Afficher le chemin
    System.out.println(fichier.getCanonicalPath());
 
  }
 
}