首页javadirectoryJava I/O - 如何获取操作系统临时目录/文件夹

Java I/O - 如何获取操作系统临时目录/文件夹

我们想知道如何获取操作系统临时目录/文件夹。
public class Main {
  public static void main(String[] args) {
    String property = "java.io.tmpdir";

    String tempDir = System.getProperty(property);
    System.out.println("OS current temporary directory is " + tempDir);
  }
}