Créer un fichier temporaire en Java
Dans ce tutoriel nous allons découvrir comment créer un fichier temporaire en Java.
Exemple:
import java.io.*;
public class Main
{
public static void main(String[] args)
{
try{
//créer un fichier temporaire
File tmp = File.createTempFile("monFichier", ".tmp");
System.out.println("Fichier Temporaire : " + tmp.getAbsolutePath());
}catch(IOException e){
e.printStackTrace();
}
}
}
import java.io.*;
public class Main
{
public static void main(String[] args)
{
try{
//créer un fichier temporaire
File tmp = File.createTempFile("monFichier", ".tmp");
System.out.println("Fichier Temporaire : " + tmp.getAbsolutePath());
}catch(IOException e){
e.printStackTrace();
}
}
}
import java.io.*; public class Main { public static void main(String[] args) { try{ //créer un fichier temporaire File tmp = File.createTempFile("monFichier", ".tmp"); System.out.println("Fichier Temporaire : " + tmp.getAbsolutePath()); }catch(IOException e){ e.printStackTrace(); } } }
Sortie: