create temporary file java program

Example:

package com.w3spoint;
 
import java.io.File;
 
public class TempFileTest {
  public static void main(String args[]){
	  File tempFile = null;
      try {
          tempFile = File.createTempFile("TempFile", ".tmp");
          System.out.println("Created Temp File Location : " 
          + tempFile.getAbsolutePath());
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
}

Output:

Created Temp File Location : C:\Users\jai\AppData\Local\Temp\TempFile8937817865485312925.tmp

Download this example.

Please follow and like us:
Content Protection by DMCA.com