Java Files create temporary file in temporary directory

Description

Java Files create temporary file in temporary directory

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {
  public static void main(String[] args) {
    try {/*  w ww.j  av a2s.  c  o  m*/

      Path p1 = Paths.get("C:/temp");
      Path tFile2 = Files.createTempFile(p1,"test", ".txt");
      System.out.println("Temp file2: " + tFile2);

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}



PreviousNext

Related