How to get the temporary file path in Java?
an Example for to get the temporary file path in Java
package com.nourit.javaIO; import java.io.File; import java.io.IOException; public class GetTempFilePath { public static void main(String[] args) { try { // create a temp file File temp = File.createTempFile("nouritTemp-file-name", ".tmp"); // Get tempropary file path String absolutePath = temp.getAbsolutePath(); System.out.println("Temp file path : " + absolutePath); } catch (IOException e) { e.printStackTrace(); } } }
Outout:
Temp file : C:\Users\MOHAME~1.PRO\AppData\Local\Temp\nouritTemp-file-name7955618864583162693.tmp